-
Notifications
You must be signed in to change notification settings - Fork 570
_test.inc.js files improperly included when not building tests #655
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
Comments
I don't think there's a special rule about Is there precedent for this in Go and its support for non-.go files like .c? |
Doesn't seem that way. https://golang.org/cmd/go/ says:
There's nothing there about _test suffix for .c, .s, .m, .swig, etc. files: |
It was an assumption on my part, that it should work that way. Perhaps a faulty one... I'll do some investigation. |
We can discuss it as a feature request and consider for inclusion if it's unavoidable. But if avoidable, we should try to avoid straying away from cmd/go mechanics.
👍 Let us know what you find out. |
So I think I was remembering the research I did on #468, and assuming the same logic would apply to So here's my attempt at making the case for supporting this: The other (non- I think GopherJS/JavaScript may be a notable exception, since it's common to want to configure Node.js especially for running tests, in ways that don't apply to a browser. In my particular case, I was wanting to run:
when running GopherJS tests, but not when building for the browser. Work-arounds are possible, such as:
The first two are a bit cumbersome for my taste. The latter is probably the most appealing, but could be pretty cumbersome in larger use-cases (but maybe those don't exist). So that's my case in favor of the change. Naturally, the counter-argument is it's non-standard, and deviates from the official cmd/go. I'm not sure it violates the spirit of the intention, but given that there are available workarounds, maybe it's best to be conservative. |
I want to think a little more about it before coming to a decision (and it'd be nice to hear @neelance's thoughts). But want to post my initial thoughts. My initial reaction/feeling is that this is likely okay. Even if it deviates a little from cmd/go, it looks like the value offered by this change would be significant. Not implementing this just because it's a little out of sync with cmd/go doesn't seem like it'd be worthwhile. Thanks for providing the rationale. |
About that specific change, I want to understand it better, so here's a question. Isn't it extremely trivial to do equivalent of // foo_test.go
package foo_test
func init() {
js.Global.Set("XMLHttpRequest", js.Global.Call("require", "xhr2"))
} Or something like that. Is this feature request because you'd prefer to write that as JavaScript in a Or is it not possible to do in a _test.go file? |
I chatted with @shurcooL on Slack about this, and I think we agree this isn't the best approach for the specific problem I'm having. The immediate solution for me was to move the code into my Go
A more general solution for getting a working |
To clarify, our discussion removed the need for this proposal to resolve a specific problem. Hence the proposal is being withdrawn/deferred. If there's a strong need for _test.inc.js that warrants making an exception and deviating from cmd/go behavior, this discussion can be had then. It's just not worth it now because there's no need right now. |
I found another use-case for excluding |
Uh oh!
There was an error while loading. Please reload this page.
To reproduce, create a simple package:
main.go:
main_test.go:
main_test.inc.js:
then compile:
And observe that the output contains the contents of the
inc.js
file:The text was updated successfully, but these errors were encountered: