testing: testlog kills tests that call m.Run multiple times #23129
After fixing #23047, running the influxdb tests turned up a failure caused by github.com/influxdata/influxdb/tests/server_test.go, which (surprise!) runs m.Run in a loop during TestMain:
This only barely works today. Flags like -test.cpuprofile overwrite the output on each iteration, so that the profile applies only to the last iteration. But it doesn't crash in Go 1.9. Now it crashes, because the second m.Run calls testlog.SetLogger, and testlog.SetLogger must only be called once.
I guess now we have to support running m.Run multiple times. Sigh.
The text was updated successfully, but these errors were encountered:
cmd/go.TestScript/test_main_twice demonstrates a program that invokes (*M).Run twice in a row. If we only restore os.Exit(0) in m.afterOnce, we will fail to restore it after the second run and fail the test process despite both runs passing. Updates #29062 Updates #23129 Change-Id: Id22ec68f1708e4583c8dda14a8ba0efae7178b85 Reviewed-on: https://go-review.googlesource.com/c/go/+/251262 Run-TryBot: Bryan C. Mills <email@example.com> Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com>