1
0
mirror of https://github.com/golang/go synced 2024-11-05 12:06:15 -07:00

cmd/go: warn on -race with -covermode=set.

Fixes #20435.

Change-Id: I15576f36b26d01642c1187325baea82d3077e578
Reviewed-on: https://go-review.googlesource.com/43777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Dhananjay Nakrani 2017-05-19 19:52:59 -07:00 committed by Brad Fitzpatrick
parent f6f1daa4b8
commit d433de6e86
2 changed files with 22 additions and 0 deletions

View File

@ -4120,3 +4120,21 @@ func TestCgoFlagContainsSpace(t *testing.T) {
tg.cd(tg.path("src/cgo")) tg.cd(tg.path("src/cgo"))
tg.run("run", "main.go") tg.run("run", "main.go")
} }
// Issue #20435.
func TestGoTestRaceCoverModeFailures(t *testing.T) {
if !canRace {
t.Skip("skipping because race detector not supported")
}
tg := testgo(t)
tg.parallel()
defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
tg.run("test", "testrace")
tg.runFail("test", "-race", "-covermode=set", "testrace")
tg.grepStderr(`-covermode must be "atomic", not "set", when -race is enabled`, "-race -covermode=set was allowed")
tg.grepBothNot("PASS", "something passed")
}

View File

@ -193,6 +193,10 @@ func testFlags(args []string) (packageNames, passToTest []string) {
} }
} }
if cfg.BuildRace && testCoverMode != "atomic" {
base.Fatalf(`-covermode must be "atomic", not %q, when -race is enabled`, testCoverMode)
}
// Tell the test what directory we're running in, so it can write the profiles there. // Tell the test what directory we're running in, so it can write the profiles there.
if testProfile && outputDir == "" { if testProfile && outputDir == "" {
dir, err := os.Getwd() dir, err := os.Getwd()