MCPcopy
hub / github.com/uber-go/zap / TestGlobalsConcurrentUse

Function TestGlobalsConcurrentUse

global_test.go:69–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func 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
100func TestNewStdLog(t *testing.T) {
101 withLogger(t, DebugLevel, []Option{AddCaller()}, func(l *Logger, logs *observer.ObservedLogs) {

Callers

nothing calls this directly

Calls 12

SleepFunction · 0.92
ReplaceGlobalsFunction · 0.85
NewNopFunction · 0.85
LFunction · 0.85
IntFunction · 0.85
DevelopmentFunction · 0.85
SFunction · 0.85
WithMethod · 0.65
AddMethod · 0.45
InfoMethod · 0.45
WithOptionsMethod · 0.45
NamedMethod · 0.45

Tested by

no test coverage detected