mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
testing: consider a test failed after race errors
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>
This commit is contained in:
parent
87bd0b2f14
commit
221541ec8c
2 changed files with 5 additions and 2 deletions
|
|
@ -181,10 +181,12 @@ func TestFail(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
x = 43
|
x = 43
|
||||||
<-done
|
<-done
|
||||||
|
t.Log(t.Failed())
|
||||||
}
|
}
|
||||||
`, `
|
`, `
|
||||||
==================
|
==================
|
||||||
--- FAIL: TestFail \(0...s\)
|
--- FAIL: TestFail \(0...s\)
|
||||||
|
.*main_test.go:13: true
|
||||||
.*testing.go:.*: race detected during execution of test
|
.*testing.go:.*: race detected during execution of test
|
||||||
FAIL`},
|
FAIL`},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -450,8 +450,9 @@ func (c *common) Fail() {
|
||||||
// Failed reports whether the function has failed.
|
// Failed reports whether the function has failed.
|
||||||
func (c *common) Failed() bool {
|
func (c *common) Failed() bool {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
defer c.mu.RUnlock()
|
failed := c.failed
|
||||||
return c.failed
|
c.mu.RUnlock()
|
||||||
|
return failed || c.raceErrors+race.Errors() > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// FailNow marks the function as having failed and stops its execution.
|
// FailNow marks the function as having failed and stops its execution.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue