(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestGlobalsConcurrentUse(t *testing.T) { |
| 70 | var ( |
| 71 | stop atomic.Bool |
| 72 | wg sync.WaitGroup |
| 73 | ) |
| 74 | |
| 75 | for i := 0; i < 100; i++ { |
| 76 | wg.Add(2) |
| 77 | go func() { |
| 78 | for !stop.Load() { |
| 79 | ReplaceGlobals(NewNop()) |
| 80 | } |
| 81 | wg.Done() |
| 82 | }() |
| 83 | go func() { |
| 84 | for !stop.Load() { |
| 85 | L().With(Int("foo", 42)).Named("main").WithOptions(Development()).Info("") |
| 86 | S().Info("") |
| 87 | } |
| 88 | wg.Done() |
| 89 | }() |
| 90 | } |
| 91 | |
| 92 | ztest.Sleep(100 * time.Millisecond) |
| 93 | // CAS loop to toggle the current value. |
| 94 | for old := stop.Load(); !stop.CompareAndSwap(old, !old); { |
| 95 | old = stop.Load() |
| 96 | } |
| 97 | wg.Wait() |
| 98 | } |
| 99 | |
| 100 | func TestNewStdLog(t *testing.T) { |
| 101 | withLogger(t, DebugLevel, []Option{AddCaller()}, func(l *Logger, logs *observer.ObservedLogs) { |
nothing calls this directly
no test coverage detected