You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger.WithCallDepth(1).Error(nil, "WARNING: test kept at least one goroutine running after test completion", "callstack", string(dbg.Stacks(false)))
254
-
l.shared.goroutineWarningDone=true
271
+
duration:=time.Since(l.shared.stopTime)
272
+
ifduration>stopGracePeriod {
273
+
274
+
logger.WithCallDepth(1).Info("WARNING: test kept at least one goroutine running after test completion", "timeSinceCompletion", duration.Round(time.Second), "callstack", string(dbg.Stacks(false)))
// All lines from the callstack get stripped. We can be sure that it was non-empty because otherwise we wouldn't
216
221
// have the < > markers.
217
222
//
218
223
// Full output:
219
-
// testinglogger_test.go:194] "WARNING: test kept at least one goroutine running after test completion" logger="TestStop/Sub leaked goroutine" callstack=<
224
+
// testinglogger_test.go:194] "WARNING: test kept at least one goroutine running after test completion" logger="TestStop/Sub leaked goroutine.me" completed=true timeSinceCompletion="15s" callstack=<
expected:=fmt.Sprintf(`testinglogger_test.go:%d] "WARNING: test kept at least one goroutine running after test completion" logger="TestStop/Sub leaked goroutine" callstack=<
237
-
>
238
-
testinglogger_test.go:%d] "simple info message" logger="TestStop/Sub leaked goroutine"
241
+
expected:=fmt.Sprintf(`testinglogger_test.go:%d] "simple info message" logger="TestStop/Sub leaked goroutine"
testinglogger_test.go:%d] "WARNING: test kept at least one goroutine running after test completion" logger="TestStop/Sub leaked goroutine.me" completed=true timeSinceCompletion="<...>s" callstack=<
244
+
>
240
245
testinglogger_test.go:%d] "complex info message" logger="TestStop/Sub leaked goroutine.me" completed=true anotherValue=1
241
246
`,
242
-
line+1, line+1, line+2, line+3)
247
+
line+1, line+2, line+4, line+4)
243
248
ifactual!=expected {
244
249
t.Errorf("Output does not match. Expected:\n%s\nActual:\n%s\n", expected, actual)
0 commit comments