aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/stub/exit.go
diff options
context:
space:
mode:
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)
+ }
+}