Description
Back when GOPATH mode was default, assuming one GOPATH workspace, running "go test ./..." in $GOPATH/src/root had the same effect as running "go test {root}/...". The latter was more explicit and did the stated thing even if it was accidentally run from the wrong directory. Maybe that's why it was chosen, or maybe it was chosen arbitrarily, since both worked and did the same thing.
That invocation persisted to today, when module mode is used, and for each module to be tested the coordinator runs "go test {module-root}/..." invocations at the module root to test packages contained inside that module:
// A goTestRun represents a single invocation of the 'go test' command.
type goTestRun struct {
Dir string // Directory where 'go test' should be executed.
Patterns []string // Import path patterns to provide to 'go test'.
}
// The default behavior is to test the pattern "golang.org/x/{repo}/..."
// in the repository root.
repoPath := importPathOfRepo(st.SubName)
testRuns := []goTestRun{{
Dir: "gopath/src/" + repoPath,
Patterns: []string{repoPath + "/..."},
}}
(source)
From #51283 I've learned there's a difference in that "{module-root}/..." may select a package with import path "{module-root}" even if that package is in another module, but "./..." won't do that.
Since there's no need for the pattern to match any packages outside of the very module it's meant to cover, we could consider switching. It would not fail if a go.sum entry that go mod tidy
doesn't currently insert isn't added in some cases (see #51283), remove possibility of unintentional duplicate coverage of packages in nested modules, and least importantly it is shorter visually.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status