From: cuiweixie Date: Sat, 27 Aug 2022 02:24:49 +0000 (+0800) Subject: testing: convert numFailed to atomic type X-Git-Tag: go1.20rc1~1369 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a1c9783ca1a98eef0fbfa46f8027e711b471b600;p=gostls13.git testing: convert numFailed to atomic type Change-Id: Ic3464e95ad8901df5477d7717760b8c6d08ce97b Reviewed-on: https://go-review.googlesource.com/c/go/+/426078 Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Auto-Submit: Bryan Mills Reviewed-by: Bryan Mills Reviewed-by: Michael Pratt --- diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index b9f3a3d159..e60ecadf25 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -14,7 +14,6 @@ import ( "path/filepath" "reflect" "runtime" - "sync/atomic" "time" ) @@ -615,7 +614,7 @@ func fRunner(f *F, fn func(*F)) { // the original panic should still be // clear. if f.Failed() { - atomic.AddUint32(&numFailed, 1) + numFailed.Add(1) } err := recover() if err == nil { 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 }