From d2ec964e9c1ec84aa2e4444783ed68018ae4d5e4 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Tue, 13 Jun 2023 16:04:06 -0400 Subject: [PATCH] cmd/dist: test all 'std cmd' packages, even ones without _test.go files Remove the optimization added in CL 10492 that skips running 'go test' on Go packages without _test.go files. By now, 'go test' can find real problems even in packages that don't have any custom tests. On my fairly fast laptop, running go test -short on all 164 normal and 96 vendored packages without tests took around 10 seconds on the first run and 2.5 seconds on the second, a small fraction of the total all.bash time. So prioritize gains in the test coverage over those savings in all.bash time. Fixes golang/go#60463. Change-Id: I3d2bec5c367de687e57131e7fd7e6b84fed30187 Reviewed-on: https://go-review.googlesource.com/c/go/+/503095 TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov Reviewed-by: Bryan Mills Auto-Submit: Dmitri Shuralyov Run-TryBot: Dmitri Shuralyov Reviewed-by: Austin Clements --- src/cmd/dist/test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 554adea1b17..5a875ebf19e 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -601,9 +601,16 @@ func (t *tester) registerTests() { } } } else { - // Use a format string to only list packages and commands that have tests. - const format = "{{if (or .TestGoFiles .XTestGoFiles)}}{{.ImportPath}}{{end}}" - cmd := exec.Command(gorootBinGo, "list", "-f", format) + // Use 'go list std cmd' to get a list of all Go packages + // that running 'go test std cmd' could find problems in. + // (In race test mode, also set -tags=race.) + // + // This includes vendored packages and other packages without + // tests so that 'dist test' finds if any of them don't build, + // have a problem reported by high-confidence vet checks that + // come with 'go test', and anything else 'go test' may check + // in the future. See go.dev/issue/60463. + cmd := exec.Command(gorootBinGo, "list") if t.race { cmd.Args = append(cmd.Args, "-tags=race") }