-
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
proposal: go test ./.../...
for submodule/multimodule projects
#59480
Comments
go test
for submodule/multimodule projectsgo test ./.../...
for submodule/multimodule projects
see also #50745 |
Thank you for the reference, there is a lot of useful discussion there. It sounds like a similar problem, I can continue discussion there. The title of that thread, however, frames this as a gap in Go workspaces, but I think this is a more general gap in any Go tooling that supports the |
@bitfield, curious what your feedback is? |
A module is the unit of versioning, so it makes sense to me that it's also the unit of testing. There's no need to have a single You're really asking for a change that would make it less painful to maintain multiple modules in a single repo, and I don't think that's something we want to make less painful. I think it should be painful, because it's a bad idea. |
@bitfield, I'm not sure I understand -- the official docs for major version bumps explicitly recommend making a new module:
Am I missing something? |
Well, publishing a new major version of a module (that is, breaking your established public API) isn't something we should encourage either. Rich Hickey makes this point persuasively: What if we never broke anything?. And it's worth noting that the Go language itself never does this, by design. It guarantees backward compatibility, and if Go can do it, so can we. If you must bump your major version, I think the best approach is probably to embrace the idea that you're publishing a whole new module (which you are). Publish it in a different repo under a new name; don't bother with |
I dont like this. I think |
This proposal has been added to the active column of the proposals project |
The consensus here seems to be that this is too special. |
Thanks for the update, @rsc -- Any link to the full discussion? Can you help me understand: Is the problem too special, or the specific proposed solution too special? Is there agreement, at least, that there is a need for a way to run all tests in all submodules from top-level in a multi-module project with a single command? The alternative is that we are forced to copy-paste some bash loops and make targets around stackoverflow 😓 If the answer is "Don't use sub-modules", then I am happy to take that advice. But that means there is a very large discrepancy between such a recommendation a LOT of the public documentation (e.g., v2 of a module, workspaces, etc). |
Based on the discussion above, this proposal seems like a likely decline. |
Sorry for the confusion. By "here" I meant the discussion on this very issue, not some other discussion. @bitfield pointed out that the module is the unit of versioning so it makes sense for it to be the unit of testing as well. To elaborate on @1268's comment, right now the meaning of It may be worth pointing out that |
This proposal has been added to the active column of the proposals project |
No change in consensus, so declined. |
- Define go.work to include all "sub" modules. - Run `go test -v github.com/knadh/koanf...` which runs test on all references in go.work doing a prefix match of the package path filtering the "go test all" behaviour of testing every single dep. Ref: golang/go#59480 (comment)
Background
As discussed in #27957,
go test
does not have a way to natively run all tests in a directory or project:go test ./...
does not run tests in submodulesgo test all
runs all dependencies, including core library. It is no longer documentedSince submodules are now officially recommended project structure (for example, v2 documentation), it becomes valuable to have a native way to run all the tests
go test ./...
, it will give me green, though the V2 test might fail.Current workarounds:
go test ./...
within each submodule, as here. The drawbacks are that a) everyone copies the same hack everywhere, and behavior could be sensitive to which shell the user/CI is using and b) managing exit status in these loops is a pain -- no easy way to get the full result of the tests (coverage, all tests, etc) and also exit with appropriate status to pass/fail.Proposal
A new argument:
go test ./.../...
that will also test submodules. This way, existing integrations are unaffected, and documentation around submodule/multimodule projects can emphasize the new feature. Stylistically, the./.../...
argument aligns with the existing simple arguments.The text was updated successfully, but these errors were encountered: