• Russ Cox's avatar
    testing: mark tests and benchmarks failed if a race occurs during execution · 43f954e0
    Russ Cox authored
    Before:
    
    $ go test -race -v -run TestRace
    === RUN   TestRace
    ==================
    WARNING: DATA RACE
    Write at 0x00c420076420 by goroutine 7:
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace.func1()
          /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:10 +0x3b
    
    Previous write at 0x00c420076420 by goroutine 6:
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
          /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:13 +0xcc
      testing.tRunner()
          /Users/rsc/go/src/testing/testing.go:656 +0x104
    
    Goroutine 7 (running) created at:
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
          /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:12 +0xbb
      testing.tRunner()
          /Users/rsc/go/src/testing/testing.go:656 +0x104
    
    Goroutine 6 (running) created at:
      testing.(*T).Run()
          /Users/rsc/go/src/testing/testing.go:693 +0x536
      testing.runTests.func1()
          /Users/rsc/go/src/testing/testing.go:877 +0xaa
      testing.tRunner()
          /Users/rsc/go/src/testing/testing.go:656 +0x104
      testing.runTests()
          /Users/rsc/go/src/testing/testing.go:883 +0x4ac
      testing.(*M).Run()
          /Users/rsc/go/src/testing/testing.go:818 +0x1c3
      main.main()
          _/Users/rsc/go/src/cmd/go/testdata/src/testrace/_test/_testmain.go:42 +0x20f
    ==================
    --- PASS: TestRace (0.00s)
    PASS
    Found 1 data race(s)
    FAIL	_/Users/rsc/go/src/cmd/go/testdata/src/testrace	1.026s
    $
    
    After:
    
    $ go test -race -v -run TestRace
    === RUN   TestRace
    ==================
    WARNING: DATA RACE
    Write at 0x00c420076420 by goroutine 7:
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace.func1()
          /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:10 +0x3b
    
    Previous write at 0x00c420076420 by goroutine 6:
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
          /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:13 +0xcc
      testing.tRunner()
          /Users/rsc/go/src/testing/testing.go:656 +0x104
    
    Goroutine 7 (running) created at:
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
          /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:12 +0xbb
      testing.tRunner()
          /Users/rsc/go/src/testing/testing.go:656 +0x104
    
    Goroutine 6 (running) created at:
      testing.(*T).Run()
          /Users/rsc/go/src/testing/testing.go:693 +0x536
      testing.runTests.func1()
          /Users/rsc/go/src/testing/testing.go:877 +0xaa
      testing.tRunner()
          /Users/rsc/go/src/testing/testing.go:656 +0x104
      testing.runTests()
          /Users/rsc/go/src/testing/testing.go:883 +0x4ac
      testing.(*M).Run()
          /Users/rsc/go/src/testing/testing.go:818 +0x1c3
      main.main()
          _/Users/rsc/go/src/cmd/go/testdata/src/testrace/_test/_testmain.go:42 +0x20f
    ==================
    --- FAIL: TestRace (0.00s)
    	testing.go:609: race detected during execution of test
    FAIL
    FAIL	_/Users/rsc/go/src/cmd/go/testdata/src/testrace	0.022s
    $
    
    Fixes #15972.
    
    Change-Id: Idb15b8ab81d65637bb535c7e275595ca4a6e450e
    Reviewed-on: https://go-review.googlesource.com/32615
    Run-TryBot: Russ Cox <rsc@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    43f954e0
Name
Last commit
Last update
..
nettrace Loading commit data...
pprof/profile Loading commit data...
race Loading commit data...
singleflight Loading commit data...
syscall Loading commit data...
testenv Loading commit data...
trace Loading commit data...