Skip to content

Commit 9ebd254

Browse files
author
Bryan C. Mills
committed
cmd/go: ignore irrelevant 'go test' failure in TestGoTestRaceInstallCgo
This test runs 'go test -race -i runtime/race' and checks that it did not overwrite cmd/cgo. If GOROOT/pkg is read-only and GOROOT/pkg/$GOOS_$GOARCH_race is not already populated, as are the conditions if the Go toolchain was installed from source as root using 'make.bash', then 'go test -race -i' itself will fail because it cannot install packages to GOROOT/pkg. However, such a failure is not relevant to the test: even if 'go test -race -i' fails, we can still verify that it did not incidentally overwrite cmd/cgo. Updates #28387 Updates #30316 Change-Id: Iff2f75a0aeb4c926290ac3062c83695604522078 Reviewed-on: https://go-review.googlesource.com/c/go/+/207959 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 104f07c commit 9ebd254

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/cmd/go/go_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -3308,7 +3308,17 @@ func TestGoTestRaceInstallCgo(t *testing.T) {
33083308
cgo := strings.TrimSpace(tg.stdout.String())
33093309
old, err := os.Stat(cgo)
33103310
tg.must(err)
3311-
tg.run("test", "-race", "-i", "runtime/race")
3311+
3312+
// For this test, we don't actually care whether 'go test -race -i' succeeds.
3313+
// It may fail, for example, if GOROOT was installed from source as root and
3314+
// is now read-only.
3315+
// We only care that — regardless of whether it succeeds — it does not
3316+
// overwrite cmd/cgo.
3317+
runArgs := []string{"test", "-race", "-i", "runtime/race"}
3318+
if status := tg.doRun(runArgs); status != nil {
3319+
tg.t.Logf("go %v failure ignored: %v", runArgs, status)
3320+
}
3321+
33123322
new, err := os.Stat(cgo)
33133323
tg.must(err)
33143324
if !new.ModTime().Equal(old.ModTime()) {

0 commit comments

Comments
 (0)