Skip to content

Commit 3c8aeaf

Browse files
committed
Fix it
1 parent 14a86c9 commit 3c8aeaf

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

internal/testutil/baseline/baseline.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,22 @@ func RunAgainstSubmodule(t *testing.T, fileName string, actual string, opts Opti
146146
writeComparison(t, actual, local, reference, true)
147147
}
148148

149-
var mkdirAllCache sync.Map
149+
var (
150+
mkdirAllCache sync.Map
151+
mkdirAllCacheMarker any = new(int)
152+
)
150153

151154
func mkdirAllCached(t *testing.T, path string) error {
152-
cached, ok := mkdirAllCache.Load(path)
153-
if ok {
154-
return cached.(error)
155+
if _, ok := mkdirAllCache.Load(path); ok {
156+
return nil
157+
}
158+
159+
if err := os.MkdirAll(path, 0o755); err != nil {
160+
return err
155161
}
156162

157-
err := os.MkdirAll(path, 0o755)
158-
cached, _ = mkdirAllCache.LoadOrStore(path, err)
159-
return cached.(error)
163+
mkdirAllCache.Store(path, mkdirAllCacheMarker)
164+
return nil
160165
}
161166

162167
func writeComparison(t *testing.T, actualContent string, local, reference string, comparingAgainstSubmodule bool) {

0 commit comments

Comments
 (0)