Skip to content

Commit

Permalink
Stop flushDaemon after test run
Browse files Browse the repository at this point in the history
This will prevent that running a single test fails due to a started
flushDaemon in the global logging state.
  • Loading branch information
katexochen committed Feb 10, 2022
1 parent 397e3c9 commit 3321b2f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion klog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ import (
// interfere with each-other.

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
exitCode := m.Run()
StopFlushDaemon()
if exitCode == 0 {
if err := goleak.Find(); err != nil {
fmt.Fprintf(os.Stderr, "goleak: %v\n", err)
exitCode = 1
}
}
os.Exit(exitCode)
}

// Test that shortHostname works as advertised.
Expand Down

0 comments on commit 3321b2f

Please sign in to comment.