Skip to content

Commit 3d051ba

Browse files
author
Bryan C. Mills
committed
cmd/dist: run a checkNotStale on the builders before running tests
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 <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent ac6d706 commit 3d051ba

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/cmd/dist/test.go

+29-21
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,35 @@ func (t *tester) run() {
139139
goInstall("go", append([]string{"-a", "-i"}, toolchain...)...)
140140
}
141141

142-
// Complete rebuild bootstrap, even with -no-rebuild.
143-
// If everything is up-to-date, this is a no-op.
144-
// If everything is not up-to-date, the first checkNotStale
145-
// during the test process will kill the tests, so we might
146-
// as well install the world.
147-
// Now that for example "go install cmd/compile" does not
148-
// also install runtime (you need "go install -i cmd/compile"
149-
// for that), it's easy for previous workflows like
150-
// "rebuild the compiler and then run run.bash"
151-
// to break if we don't automatically refresh things here.
152-
// Rebuilding is a shortened bootstrap.
153-
// See cmdbootstrap for a description of the overall process.
154-
//
155-
// But don't do this if we're running in the Go build system,
156-
// where cmd/dist is invoked many times. This just slows that
157-
// down (Issue 24300).
158-
if !t.listMode && os.Getenv("GO_BUILDER_NAME") == "" {
159-
goInstall("go", append([]string{"-i"}, toolchain...)...)
160-
goInstall("go", append([]string{"-i"}, toolchain...)...)
161-
goInstall("go", "std", "cmd")
162-
checkNotStale("go", "std", "cmd")
142+
if !t.listMode {
143+
if os.Getenv("GO_BUILDER_NAME") == "" {
144+
// Complete rebuild bootstrap, even with -no-rebuild.
145+
// If everything is up-to-date, this is a no-op.
146+
// If everything is not up-to-date, the first checkNotStale
147+
// during the test process will kill the tests, so we might
148+
// as well install the world.
149+
// Now that for example "go install cmd/compile" does not
150+
// also install runtime (you need "go install -i cmd/compile"
151+
// for that), it's easy for previous workflows like
152+
// "rebuild the compiler and then run run.bash"
153+
// to break if we don't automatically refresh things here.
154+
// Rebuilding is a shortened bootstrap.
155+
// See cmdbootstrap for a description of the overall process.
156+
goInstall("go", append([]string{"-i"}, toolchain...)...)
157+
goInstall("go", append([]string{"-i"}, toolchain...)...)
158+
goInstall("go", "std", "cmd")
159+
} else {
160+
// The Go builder infrastructure should always begin running tests from a
161+
// clean, non-stale state, so there is no need to rebuild the world.
162+
// Instead, we can just check that it is not stale, which may be less
163+
// expensive (and is also more likely to catch bugs in the builder
164+
// implementation).
165+
willTest := []string{"std"}
166+
if t.shouldTestCmd() {
167+
willTest = append(willTest, "cmd")
168+
}
169+
checkNotStale("go", willTest...)
170+
}
163171
}
164172

165173
t.timeoutScale = 1

0 commit comments

Comments
 (0)