Commit b8e2ffcb authored by Michael Matloob's avatar Michael Matloob

cmd/go: convert tests using testdata/src/testrace to script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: Id4c2c58167d5cfc80b0d81ca9ce3db678242c06c
Reviewed-on: https://go-review.googlesource.com/c/go/+/213128
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent 249c85d3
...@@ -3092,29 +3092,6 @@ func TestGoTestRaceInstallCgo(t *testing.T) { ...@@ -3092,29 +3092,6 @@ func TestGoTestRaceInstallCgo(t *testing.T) {
} }
} }
func TestGoTestRaceFailures(t *testing.T) {
tooSlow(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", "testrace")
tg.grepStdout("FAIL: TestRace", "TestRace did not fail")
tg.grepBothNot("PASS", "something passed")
tg.runFail("test", "-race", "testrace", "-run", "XXX", "-bench", ".")
tg.grepStdout("FAIL: BenchmarkRace", "BenchmarkRace did not fail")
tg.grepBothNot("PASS", "something passed")
}
func TestGoGetUpdate(t *testing.T) { func TestGoGetUpdate(t *testing.T) {
// golang.org/issue/9224. // golang.org/issue/9224.
// The recursive updating was trying to walk to // The recursive updating was trying to walk to
...@@ -4028,25 +4005,6 @@ func TestCgoFlagContainsSpace(t *testing.T) { ...@@ -4028,25 +4005,6 @@ func TestCgoFlagContainsSpace(t *testing.T) {
tg.grepStderrNot(`"-L[^"]+c flags".*"-L[^"]+c flags"`, "found too many quoted ld flags") tg.grepStderrNot(`"-L[^"]+c flags".*"-L[^"]+c flags"`, "found too many quoted ld flags")
} }
// Issue #20435.
func TestGoTestRaceCoverModeFailures(t *testing.T) {
tooSlow(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")
}
// Issue 9737: verify that GOARM and GO386 affect the computed build ID. // Issue 9737: verify that GOARM and GO386 affect the computed build ID.
func TestBuildIDContainsArchModeEnv(t *testing.T) { func TestBuildIDContainsArchModeEnv(t *testing.T) {
if testing.Short() { if testing.Short() {
......
[short] skip
[!race] skip
go test testrace
! go test -race testrace
stdout 'FAIL: TestRace'
! stdout 'PASS'
! stderr 'PASS'
! go test -race testrace -run XXX -bench .
stdout 'FAIL: BenchmarkRace'
! stdout 'PASS'
! stderr 'PASS'
-- testrace/race_test.go --
package testrace package testrace
import "testing" import "testing"
......
[short] skip
[!race] skip
# Make sure test is functional.
go test testrace
# Now, check that -race -covermode=set is not allowed.
! go test -race -covermode=set testrace
stderr '-covermode must be "atomic", not "set", when -race is enabled'
! stdout PASS
! stderr PASS
-- testrace/race_test.go --
package testrace
import "testing"
func TestRace(t *testing.T) {
for i := 0; i < 10; i++ {
c := make(chan int)
x := 1
go func() {
x = 2
c <- 1
}()
x = 3
<-c
_ = x
}
}
func BenchmarkRace(b *testing.B) {
for i := 0; i < b.N; i++ {
c := make(chan int)
x := 1
go func() {
x = 2
c <- 1
}()
x = 3
<-c
_ = x
}
}
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