]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: go test -race -i runtime/race must not install race-enabled cmd/cgo
authorRuss Cox <rsc@golang.org>
Tue, 14 Jul 2015 05:14:08 +0000 (01:14 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 15 Jul 2015 04:27:17 +0000 (04:27 +0000)
Fix now uses same test as 'go build'.

Fixes #10500.

Change-Id: I2fcf2d95430643370aa29165d89a188988dee446
Reviewed-on: https://go-review.googlesource.com/12174
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/go/go_test.go
src/cmd/go/test.go

index 61eecbebad9ed092e6181e0ca7ef9a7d6a5cb1d7..59e90b7f6037d91a7837b4cea8159bc381f12017 100644 (file)
@@ -2077,3 +2077,20 @@ func TestGoInstallPkgdir(t *testing.T) {
        _, err = os.Stat(filepath.Join(pkg, "runtime.a"))
        tg.must(err)
 }
+
+func TestGoTestRaceInstallCgo(t *testing.T) {
+       // golang.org/issue/10500.
+       // This used to install a race-enabled cgo.
+       tg := testgo(t)
+       defer tg.cleanup()
+       tg.run("tool", "-n", "cgo")
+       cgo := strings.TrimSpace(tg.stdout.String())
+       old, err := os.Stat(cgo)
+       tg.must(err)
+       tg.run("test", "-race", "-i", "runtime/race")
+       new, err := os.Stat(cgo)
+       tg.must(err)
+       if new.ModTime() != old.ModTime() {
+               t.Fatalf("go test -i runtime/race reinstalled cmd/cgo")
+       }
+}
index 7ea8d53ad17ce3f9acc3c7e468bbb5cbe3409898..e62f4bd19d4f1647b7c356206ae5414678741158 100644 (file)
@@ -386,7 +386,7 @@ func runTest(cmd *Command, args []string) {
                if deps["C"] {
                        delete(deps, "C")
                        deps["runtime/cgo"] = true
-                       if buildContext.GOOS == runtime.GOOS && buildContext.GOARCH == runtime.GOARCH {
+                       if goos == runtime.GOOS && goarch == runtime.GOARCH && !buildRace {
                                deps["cmd/cgo"] = true
                        }
                }