aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist/test.go
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2023-06-13 20:14:26 -0400
committerGopher Robot <gobot@golang.org>2023-07-27 17:32:21 +0000
commitd79ec708bdaf27933058551b2d24a1a8e569c0d1 (patch)
tree52c01592891bf7bd945c521854da09e8286d19f4 /src/cmd/dist/test.go
parentd2ec964e9c1ec84aa2e4444783ed68018ae4d5e4 (diff)
downloadgo-d79ec708bdaf27933058551b2d24a1a8e569c0d1.tar.gz
go-d79ec708bdaf27933058551b2d24a1a8e569c0d1.zip
cmd/dist: skip testing packages without tests in short test mode
For short all.bash, we can keep the small speedup of 2-10 seconds by skipping 'go test' on packages without tests. This is viable without coverage loss since the Go release process is guaranteed to run long tests for all first class ports. For golang/go#60463. Change-Id: Ib5a6bd357d757141bc8f1c1dec148a6565726587 Reviewed-on: https://go-review.googlesource.com/c/go/+/503115 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/cmd/dist/test.go')
-rw-r--r--src/cmd/dist/test.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 5a875ebf19..8fea9fc76e 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -605,12 +605,18 @@ func (t *tester) registerTests() {
// 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.
+ // In long test mode, 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 it
+ // may check in the future. See go.dev/issue/60463.
cmd := exec.Command(gorootBinGo, "list")
+ if t.short {
+ // In short test mode, use a format string to only
+ // list packages and commands that have tests.
+ const format = "{{if (or .TestGoFiles .XTestGoFiles)}}{{.ImportPath}}{{end}}"
+ cmd.Args = append(cmd.Args, "-f", format)
+ }
if t.race {
cmd.Args = append(cmd.Args, "-tags=race")
}