Commit 6ab582a8 authored by Russ Cox's avatar Russ Cox

cmd/go: go test -race -i runtime/race must not install race-enabled cmd/cgo

Fix now uses same test as 'go build'.

Fixes #10500.

Change-Id: I2fcf2d95430643370aa29165d89a188988dee446
Reviewed-on: https://go-review.googlesource.com/12174Reviewed-by: 's avatarRob Pike <r@golang.org>
parent 91a480c3
......@@ -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")
}
}
......@@ -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
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment