]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: run a checkNotStale on the builders before running tests
authorBryan C. Mills <bcmills@google.com>
Wed, 18 Mar 2020 01:29:54 +0000 (21:29 -0400)
committerBryan C. Mills <bcmills@google.com>
Tue, 12 Oct 2021 21:15:50 +0000 (21:15 +0000)
This should be a no-op, but if the sharded builders are for some
reason distributing stale snapshots — or testing them with mismatched
environments — this should catch them out at a relatively low cost
(#24300 notwithstanding).

Given the frequently at which (*tester).runPending already checks for
staleness, we do not expect the impact of this extra check to be
significant for most builders.

For #33598
Updates #24300

Change-Id: I197d6a69c72e2eec9e4563b459206de76c89e8a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/223755
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/cmd/dist/test.go

index de9135c3c4152bbf6908c7290251f0805a7d7187..5935011e197b69b6b610f83239547f1e838fb9df 100644 (file)
@@ -139,27 +139,35 @@ func (t *tester) run() {
                goInstall("go", append([]string{"-a", "-i"}, toolchain...)...)
        }
 
-       // Complete rebuild bootstrap, even with -no-rebuild.
-       // If everything is up-to-date, this is a no-op.
-       // If everything is not up-to-date, the first checkNotStale
-       // during the test process will kill the tests, so we might
-       // as well install the world.
-       // Now that for example "go install cmd/compile" does not
-       // also install runtime (you need "go install -i cmd/compile"
-       // for that), it's easy for previous workflows like
-       // "rebuild the compiler and then run run.bash"
-       // to break if we don't automatically refresh things here.
-       // Rebuilding is a shortened bootstrap.
-       // See cmdbootstrap for a description of the overall process.
-       //
-       // But don't do this if we're running in the Go build system,
-       // where cmd/dist is invoked many times. This just slows that
-       // down (Issue 24300).
-       if !t.listMode && os.Getenv("GO_BUILDER_NAME") == "" {
-               goInstall("go", append([]string{"-i"}, toolchain...)...)
-               goInstall("go", append([]string{"-i"}, toolchain...)...)
-               goInstall("go", "std", "cmd")
-               checkNotStale("go", "std", "cmd")
+       if !t.listMode {
+               if os.Getenv("GO_BUILDER_NAME") == "" {
+                       // Complete rebuild bootstrap, even with -no-rebuild.
+                       // If everything is up-to-date, this is a no-op.
+                       // If everything is not up-to-date, the first checkNotStale
+                       // during the test process will kill the tests, so we might
+                       // as well install the world.
+                       // Now that for example "go install cmd/compile" does not
+                       // also install runtime (you need "go install -i cmd/compile"
+                       // for that), it's easy for previous workflows like
+                       // "rebuild the compiler and then run run.bash"
+                       // to break if we don't automatically refresh things here.
+                       // Rebuilding is a shortened bootstrap.
+                       // See cmdbootstrap for a description of the overall process.
+                       goInstall("go", append([]string{"-i"}, toolchain...)...)
+                       goInstall("go", append([]string{"-i"}, toolchain...)...)
+                       goInstall("go", "std", "cmd")
+               } else {
+                       // The Go builder infrastructure should always begin running tests from a
+                       // clean, non-stale state, so there is no need to rebuild the world.
+                       // Instead, we can just check that it is not stale, which may be less
+                       // expensive (and is also more likely to catch bugs in the builder
+                       // implementation).
+                       willTest := []string{"std"}
+                       if t.shouldTestCmd() {
+                               willTest = append(willTest, "cmd")
+                       }
+                       checkNotStale("go", willTest...)
+               }
        }
 
        t.timeoutScale = 1