Skip to content

Commit

Permalink
exit_test.go: avoid depending on side effect of other tests
Browse files Browse the repository at this point in the history
Logging to file must be enabled explicitly. This happened to work
randomly before, depending on which other tests were run.
  • Loading branch information
pohly committed Mar 15, 2022
1 parent 56b8a4e commit ead10d1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions exit_test.go
Expand Up @@ -24,10 +24,13 @@ import (

func ExampleFlushAndExit() {
// Set up klog so that we can test it below.

var fs flag.FlagSet
klog.InitFlags(&fs)
fs.Set("skip_headers", "true")
defer flag.Set("skip_headers", "false")
fs.Set("logtostderr", "false")
defer fs.Set("logtostderr", "true")
klog.SetOutput(os.Stdout)
defer klog.SetOutput(nil)
klog.OsExit = func(exitCode int) {
Expand Down

0 comments on commit ead10d1

Please sign in to comment.