diff options
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/testing.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go index d0334243f4..01743969ee 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1533,11 +1533,15 @@ func (m *M) before() { // after runs after all testing. func (m *M) after() { m.afterOnce.Do(func() { - if *panicOnExit0 { - m.deps.SetPanicOnExit0(false) - } m.writeProfiles() }) + + // Restore PanicOnExit0 after every run, because we set it to true before + // every run. Otherwise, if m.Run is called multiple times the behavior of + // os.Exit(0) will not be restored after the second run. + if *panicOnExit0 { + m.deps.SetPanicOnExit0(false) + } } func (m *M) writeProfiles() { |
