aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.go
diff options
context:
space:
mode:
authorcuiweixie <cuiweixie@gmail.com>2022-08-27 10:24:49 +0800
committerGopher Robot <gobot@golang.org>2022-08-29 14:52:44 +0000
commita1c9783ca1a98eef0fbfa46f8027e711b471b600 (patch)
treea01a68706711c18581ea9a4c6dc52e9a0cc001a4 /src/testing/testing.go
parent863d57cc7df5b1604d501892b7293efe0fa7e690 (diff)
downloadgo-a1c9783ca1a98eef0fbfa46f8027e711b471b600.tar.xz
testing: convert numFailed to atomic type
Change-Id: Ic3464e95ad8901df5477d7717760b8c6d08ce97b Reviewed-on: https://go-review.googlesource.com/c/go/+/426078 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/testing/testing.go')
-rw-r--r--src/testing/testing.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index ec2d864822..a38b40e38d 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -443,7 +443,7 @@ var (
cpuList []int
testlogFile *os.File
- numFailed uint32 // number of test failures
+ numFailed atomic.Uint32 // number of test failures
)
type chattyPrinter struct {
@@ -1312,7 +1312,7 @@ func tRunner(t *T, fn func(t *T)) {
// a signal saying that the test is done.
defer func() {
if t.Failed() {
- atomic.AddUint32(&numFailed, 1)
+ numFailed.Add(1)
}
if t.raceErrors+race.Errors() > 0 {
@@ -2064,5 +2064,5 @@ func parseCpuList() {
}
func shouldFailFast() bool {
- return *failFast && atomic.LoadUint32(&numFailed) > 0
+ return *failFast && numFailed.Load() > 0
}