Skip to content

Commit

Permalink
Race in setting Config.Level: Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Oct 2, 2024
1 parent e9a4588 commit 63ad039
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,21 @@ func TestInvalidFile(t *testing.T) {
}
}

func TestConcurrentLevelSet(t *testing.T) {
// This test is to make sure that setting the log level concurrently
// doesn't cause a -race failure. Shows up in dflag/ for instance with configmap changes.
var wg sync.WaitGroup
wg.Add(int(Fatal - Verbose))
for i := Verbose; i < Fatal; i++ {
go func() {
SetLogLevel(i)
wg.Done()
}()
}
wg.Wait()
SetLogLevel(Info)
}

// --- Benchmarks

// This `discard` is like io.Discard, except that io.Discard is checked explicitly
Expand Down

0 comments on commit 63ad039

Please sign in to comment.