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
funcTestPanicSwallowedByCleanup(t*testing.T) {
t.Cleanup(func() {
// This causes the panic to never be logged:t.Fatal("problem during cleanup")
})
panic("kaboom")
}
What did you expect to see?
The panic encountered in the test to be reported with a full stack trace, as would be the case if t.Error was called from the t.Cleanup, see: https://go.dev/play/p/iV4-JV4ArBf
=== RUN TestPanicWithCleanup
prog.go:10: problem during cleanup
--- FAIL: TestPanicWithCleanup (0.00s)
panic: kaboom [recovered]
panic: kaboom
goroutine 6 [running]:
testing.tRunner.func1.2({0x4b6440, 0x4ee1a8})
/usr/local/go-faketime/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
/usr/local/go-faketime/src/testing/testing.go:1212 +0x218
panic({0x4b6440, 0x4ee1a8})
/usr/local/go-faketime/src/runtime/panic.go:1038 +0x215
main.TestPanicWithCleanup(0xc000001ba0)
/tmp/sandbox3107448856/prog.go:12 +0x65
testing.tRunner(0xc000001ba0, 0x4d4d80)
/usr/local/go-faketime/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
/usr/local/go-faketime/src/testing/testing.go:1306 +0x35a
Program exited.
What did you see instead?
The original panic is completely omitted, we only see the t.Fatal output:
=== RUN TestPanicSwallowedByCleanup
prog.go:10: problem during cleanup
--- FAIL: TestPanicSwallowedByCleanup (0.00s)
FAIL
Program exited.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, including go1.18rc1.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Called
t.Fatal
from at.Cleanup
function for a test that panicked, see: https://go.dev/play/p/Q3zMx79r8gAWhat did you expect to see?
The panic encountered in the test to be reported with a full stack trace, as would be the case if
t.Error
was called from thet.Cleanup
, see: https://go.dev/play/p/iV4-JV4ArBfWhat did you see instead?
The original panic is completely omitted, we only see the t.Fatal output:
Note, this is possibly related to: #49929
The text was updated successfully, but these errors were encountered: