aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/stub/exit.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-04 19:39:12 +0900
committerOphestra <cat@gensokyo.uk>2025-09-04 19:39:12 +0900
commit3920acf8c215a30bc3b48408cf46a3951ec04555 (patch)
tree82ac0cb4af518165114ee17b6c7796999ac40136 /container/stub/exit.go
parent19630a95932451b4df3f6fd70e88aef9303235e9 (diff)
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 <cat@gensokyo.uk>
Diffstat (limited to 'container/stub/exit.go')
-rw-r--r--container/stub/exit.go26
1 files changed, 17 insertions, 9 deletions
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)
+ }
+}