From 3920acf8c215a30bc3b48408cf46a3951ec04555 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 4 Sep 2025 19:39:12 +0900 Subject: container/stub: remove function call in handleExit This gets inlined and does not cause problems usually but turns out -coverpkg uninlines it and breaks the recovery. Signed-off-by: Ophestra --- container/stub/exit.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'container/stub/exit.go') diff --git a/container/stub/exit.go b/container/stub/exit.go index 0f44b5dc..6470fe6e 100644 --- a/container/stub/exit.go +++ b/container/stub/exit.go @@ -12,20 +12,13 @@ const ( ) // HandleExit must be deferred before calling with the stub. -func (s *Stub[K]) HandleExit() { handleExit(s.TB, true) } - -func handleExit(t testing.TB, root bool) { +func HandleExit(t testing.TB) { switch r := recover(); r { case PanicExit: break case panicFailNow: - if root { - t.FailNow() - } else { - t.Fail() - } - break + t.FailNow() case panicFatal, panicFatalf, nil: break @@ -34,3 +27,18 @@ func handleExit(t testing.TB, root bool) { panic(r) } } + +// handleExitNew handles exits from goroutines created by [Stub.New]. +func handleExitNew(t testing.TB) { + switch r := recover(); r { + case PanicExit, panicFatal, panicFatalf, nil: + break + + case panicFailNow: + t.Fail() + break + + default: + panic(r) + } +} -- cgit v1.3.1