File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import (
15
15
"regexp"
16
16
"runtime"
17
17
"strings"
18
+ "sync/atomic"
18
19
"testing"
19
20
"time"
20
21
@@ -54,7 +55,7 @@ type fetchDescriptor struct {
54
55
Arch string
55
56
Version string
56
57
RealVersion string
57
- cached * bool
58
+ cached atomic. Bool
58
59
}
59
60
60
61
var embedDB = fetchDescriptor {
@@ -125,17 +126,16 @@ var versionRE = regexp.MustCompile(`^[0-9]+((\.[0-9]+){2})?$`)
125
126
126
127
func (a * fetchDescriptor ) DiscoverVersion (t testing.TB ) {
127
128
skip := skip () || testing .Short ()
128
- if a . cached != nil && ( ! * a .cached && skip ) {
129
+ if ! a .cached . Load () && skip {
129
130
t .Skip ("skipping integration test: would need to fetch bom & binaries" )
130
131
}
131
132
shouldFetch := false
132
133
defer func () {
133
- a .cached = new (bool )
134
134
if t .Failed () || t .Skipped () {
135
- * a .cached = false
135
+ a .cached . Store ( false )
136
136
return
137
137
}
138
- * a .cached = ! shouldFetch
138
+ a .cached . Store ( ! shouldFetch )
139
139
if ! shouldFetch {
140
140
// If it does exist, wait until we can grab a shared lock. If this blocks,
141
141
// it's because another process has the exclusive (write) lock. Any error
@@ -248,7 +248,7 @@ func (a *fetchDescriptor) DiscoverVersion(t testing.TB) {
248
248
}
249
249
250
250
func (a * fetchDescriptor ) FetchArchive (t testing.TB ) {
251
- if * a .cached {
251
+ if a .cached . Load () {
252
252
return
253
253
}
254
254
p := a .Realpath (t )
You can’t perform that action at this time.
0 commit comments