]> Cypherpunks repositories - gostls13.git/commitdiff
testing: consider a test failed after race errors
authorCaleb Spare <cespare@gmail.com>
Fri, 7 Apr 2017 01:47:01 +0000 (18:47 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 10 Apr 2017 14:36:02 +0000 (14:36 +0000)
Fixes #19851.

Change-Id: I5ee9533406542be7d5418df154f6134139e75892
Reviewed-on: https://go-review.googlesource.com/39890
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/race/output_test.go
src/testing/testing.go

index 587540f5e86ffdd609b53d5051c54187c090947e..e73e6b3bfc14c204edc406131cca3af71a8f7fea 100644 (file)
@@ -181,10 +181,12 @@ func TestFail(t *testing.T) {
        }()
        x = 43
        <-done
+       t.Log(t.Failed())
 }
 `, `
 ==================
 --- FAIL: TestFail \(0...s\)
+.*main_test.go:13: true
 .*testing.go:.*: race detected during execution of test
 FAIL`},
 
index d63d5d85a754fbc953029805f949cbbcaf2ac0b8..130977f106cc4fd354a6c062bbd5d0a2e2d9681b 100644 (file)
@@ -450,8 +450,9 @@ func (c *common) Fail() {
 // Failed reports whether the function has failed.
 func (c *common) Failed() bool {
        c.mu.RLock()
-       defer c.mu.RUnlock()
-       return c.failed
+       failed := c.failed
+       c.mu.RUnlock()
+       return failed || c.raceErrors+race.Errors() > 0
 }
 
 // FailNow marks the function as having failed and stops its execution.