-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: cgo from within gotest #4030
Comments
I'm a bit confused. It sounds like you think I said the answer is to package up the C functionality you need during your test in some other package and then import that "external" package. What I'm saying is that import "C" is an implementation detail of the package you are trying to test. The test itself shouldn't need to import "C" at all. Russ |
> I'm a bit confused. It sounds like you think I said the answer is to > package up the C functionality you need during your test in some other > package and then import that "external" package. No, I follow your reasoning completely. There's nothing wrong with saving some labor by requiring some indirection, and it actually may better isolate the issue. It's just counterintuitive. |
Wanting to use cgo in a test seems reasonable to me. |
You can use cgo in non _test.go files.
See how the cgo test itself is written. http://golang.org/misc/cgo/test/
Basically, in http://golang.org/misc/cgo/test/cgo_test.go, we directly
each TestXXX(t *testing.T) to testXXX(t) defined in other files that
can use cgo.
|
On Tue, Feb 24, 2015 at 12:31 AM, Minux Ma notifications@github.com wrote:
Thanks. Manlio Perillo |
If you actually read the code that I provided, you will see that you don't
need to create another package.
|
On Tue, Feb 24, 2015 at 9:09 PM, Minux Ma notifications@github.com wrote:
The alternative is to put cgo code inside the package being tested, but Ideally I would like to have the cgo code built and used only by the test Thanks —
|
Of course not. There are some packages under misc/cgo/test, but that is
because of other constraints.
See cgo_test.go and issueNNNN.go.
|
by d.wright.dev:
The text was updated successfully, but these errors were encountered: