]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: test all 'std cmd' packages, even ones without _test.go files
authorDmitri Shuralyov <dmitshur@golang.org>
Tue, 13 Jun 2023 20:04:06 +0000 (16:04 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 27 Jul 2023 17:32:18 +0000 (17:32 +0000)
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 <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/dist/test.go

index 554adea1b17ba51ba7bdab61ee482cf733402b3c..5a875ebf19e2eb9a4cd07fc0c2795c72dc673320 100644 (file)
@@ -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")
                }