Skip to content

Commit edbc1d3

Browse files
lsytj0413sebsoto
authored andcommittedApr 10, 2020
test(*): TestRollover failed randomly on Windows
1 parent 4cae117 commit edbc1d3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎klog_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"runtime"
2929
"strconv"
3030
"strings"
31+
"sync"
3132
"testing"
3233
"time"
3334
)
@@ -317,13 +318,16 @@ func TestVmoduleOff(t *testing.T) {
317318
func TestSetOutputDataRace(t *testing.T) {
318319
setFlags()
319320
defer logging.swap(logging.newBuffers())
321+
var wg sync.WaitGroup
320322
for i := 1; i <= 50; i++ {
321323
go func() {
322324
logging.flushDaemon()
323325
}()
324326
}
325327
for i := 1; i <= 50; i++ {
328+
wg.Add(1)
326329
go func() {
330+
defer wg.Done()
327331
SetOutput(ioutil.Discard)
328332
}()
329333
}
@@ -333,7 +337,9 @@ func TestSetOutputDataRace(t *testing.T) {
333337
}()
334338
}
335339
for i := 1; i <= 50; i++ {
340+
wg.Add(1)
336341
go func() {
342+
defer wg.Done()
337343
SetOutputBySeverity("INFO", ioutil.Discard)
338344
}()
339345
}
@@ -342,6 +348,7 @@ func TestSetOutputDataRace(t *testing.T) {
342348
logging.flushDaemon()
343349
}()
344350
}
351+
wg.Wait()
345352
}
346353

347354
// vGlobs are patterns that match/don't match this file at V=2.

0 commit comments

Comments
 (0)
Please sign in to comment.