-
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
cmd/go: document that directory patterns only match dirs in current module #27957
Comments
A related comment is that the behavior of These two snippets from the documentation for
seems to imply that ./... would descend into another module in a subdirectory IF that module is a dependency of the current module (that is, if a module in a subdirectory is part of the "active modules"). However, it is not clear if that is specific to (edit: as far as I can tell and as I tried to outline below in #27957 (comment), it seems there are a slightly different set of rules applied to module patterns vs. module-enabled package patterns, and |
Per our Slack conversation, that doesn't appear to be the case:
I'm not entirely sure whether that's a bug given the documentation you've highlighted @thepudds |
The clearest description I think I've seen of the meaning of common package patterns in a module world is from the
And there are a slightly different set of rules applied if a module pattern is being supplied via a One difference is
I'm not sure that is documented. The behavior of
So summarizing in terms of what might be missing from the current documentation, it seems:
All that said, the documentation comments here are based on some quick Ctrl-F and basic grepping, so easily could have missed something that is actually there in the doc, and of course other people might have other behavior in mind that is not documented either. |
OK, so trying to summarize this discussion, it sounds like there are three things we should do to mark this bug closed:
|
Ensuring tests do not write to the current directory sounds ok. But, what's the point of running the tests again for the standard packages? On my workstation with google internal go distribution, I get various errors from standard package tests, not necessarily related to the permission issues. Here are some of the errors not involving permission issues. mime/multipart: (I don't know why) --- FAIL: TestNested (0.00s) multipart_test.go:466: reading text/plain part: got "*body*\n", net: bad test? flakiness? 2018/10/25 14:21:50 http: TLS handshake error from 127.0.0.1:57808: read tcp 127.0.0.1:34383- >127.0.0.1:57808: use of closed network connection --- FAIL: TestServerValidatesHostHeader (0.00s) serve_test.go:4667: For HTTP/1.1 "", Status = 200; want 400 runtime: bad test or flakiness (TestSchedStat/base) time: panic: cannot load America/Los_Angeles for testing: unknown time zone America/Los_Angeles |
If the standard-library tests are flaky, we should either fix them or Beyond that, at some point we might want to allow And if something about a particular platform or machine actually breaks non-flaky tests in the standard library, that's a useful signal too: it tells users that the error may be in their system configuration (or the standard library) rather than their application code. (Remember that these test results will be cached, so they should only re-run when the cache is cold.) |
That may be a good feature for Go maintainers. Ideally those flakiness should be caught before official Go release but in practice this thing happens. For users of already released Go tools and libraries, it means they should live with the noise until the new release with the fix is available, which makes use of |
Assuming this is all behaving as expected, I've just realised my error in #27957 (comment).
@bcmills I suspect this is what you were referring to in #27957 (comment) about clarifying that distinction in the docs. |
|
@myitcv or other, I understand that one view is that different modules are a different workspace. However, this intuition doesn't exactly hold when we are talking about v2s: https://go.dev/blog/v2-go-modules Now, imagine your CI platform is testing the code -- the recommendation is to use It would greatly improve usability to have a I propose:
I personally would be happy to open either of these PRs, if there was some guidance from the committers that there's some support. I created a proposal issue. |
This involves both documentation and the implementation (which I don't know it's intended or something to fix). Feel free to split this issue if necessary.
All experiments here are done outside GOPATH.
I have a two module
testmod2
andtestmod2/cmd
in one single repo.The latest
testmod2/cmd
(v0.0.2) depends ontestmod2/v2
.There are tests in testmod2/lib and testmod2/cmd packages.
go test ./...
doesn't cross the module boundary, so tests in testmod2/cmd didn' run.go test ./cmd/...
doesn't work either because of the same reason. If we ever allow submodules in a single repo, this needs to be documented in https://tip.golang.org/cmd/go/#hdr-Package_lists_and_patterns.AFAIK, there is no automatic way to invoke all tests in the repo when submodules are involved. That's intended because module is like a separate workspace (as discussed in cmd/go: setting up a multi-module single repo is difficult #27056).
As specified in the [ Package lists and patterns] section,
all
can be used to test all modules the current module depends on. That implies testing in the standard libraries as well.This unfortunate case I encountered is the failures from the tests in the standard libraries. The above error was because I have no permission to write to the GOROOT. I think that's not a rare setup so running standard library tests doesn't seem to be a right choice.
The text was updated successfully, but these errors were encountered: