Commit d433de6e authored by Dhananjay Nakrani's avatar Dhananjay Nakrani Committed by Brad Fitzpatrick

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

Fixes #20435.

Change-Id: I15576f36b26d01642c1187325baea82d3077e578
Reviewed-on: https://go-review.googlesource.com/43777Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent f6f1daa4
......@@ -4120,3 +4120,21 @@ func TestCgoFlagContainsSpace(t *testing.T) {
tg.cd(tg.path("src/cgo"))
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")
}
......@@ -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.
if testProfile && outputDir == "" {
dir, err := os.Getwd()
......
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