1
0
mirror of https://github.com/golang/go synced 2024-11-26 04:17:59 -07:00

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>
This commit is contained in:
cuiweixie 2022-08-27 10:24:49 +08:00 committed by Gopher Robot
parent 863d57cc7d
commit a1c9783ca1
2 changed files with 4 additions and 5 deletions

View File

@ -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 {

View File

@ -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
}