]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: ignore irrelevant 'go test' failure in TestGoTestRaceInstallCgo
authorBryan C. Mills <bcmills@google.com>
Tue, 19 Nov 2019 17:05:30 +0000 (12:05 -0500)
committerBryan C. Mills <bcmills@google.com>
Tue, 19 Nov 2019 18:14:44 +0000 (18:14 +0000)
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 <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go

index 3760703fee948fc4f3380a6c8a7ed73ecd45d646..b6d355ee314c99c6ff689c30cb13a032f07831a9 100644 (file)
@@ -3308,7 +3308,17 @@ func TestGoTestRaceInstallCgo(t *testing.T) {
        cgo := strings.TrimSpace(tg.stdout.String())
        old, err := os.Stat(cgo)
        tg.must(err)
-       tg.run("test", "-race", "-i", "runtime/race")
+
+       // For this test, we don't actually care whether 'go test -race -i' succeeds.
+       // It may fail, for example, if GOROOT was installed from source as root and
+       // is now read-only.
+       // We only care that — regardless of whether it succeeds — it does not
+       // overwrite cmd/cgo.
+       runArgs := []string{"test", "-race", "-i", "runtime/race"}
+       if status := tg.doRun(runArgs); status != nil {
+               tg.t.Logf("go %v failure ignored: %v", runArgs, status)
+       }
+
        new, err := os.Stat(cgo)
        tg.must(err)
        if !new.ModTime().Equal(old.ModTime()) {