aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/stub/exit_test.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_test.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_test.go')
-rw-r--r--container/stub/exit_test.go42
1 files changed, 28 insertions, 14 deletions
diff --git a/container/stub/exit_test.go b/container/stub/exit_test.go
index 02c4af89..4e935ff4 100644
--- a/container/stub/exit_test.go
+++ b/container/stub/exit_test.go
@@ -7,8 +7,8 @@ import (
"hakurei.app/container/stub"
)
-//go:linkname handleExit hakurei.app/container/stub.handleExit
-func handleExit(_ testing.TB, _ bool)
+//go:linkname handleExitNew hakurei.app/container/stub.handleExitNew
+func handleExitNew(_ testing.TB)
// overrideTFailNow overrides the Fail and FailNow method.
type overrideTFailNow struct {
@@ -33,7 +33,7 @@ func (o *overrideTFailNow) Fail() {
func TestHandleExit(t *testing.T) {
t.Run("exit", func(t *testing.T) {
- defer handleExit(t, true)
+ defer stub.HandleExit(t)
panic(stub.PanicExit)
})
@@ -45,7 +45,7 @@ func TestHandleExit(t *testing.T) {
t.Errorf("FailNow was never called")
}
}()
- defer handleExit(ot, true)
+ defer stub.HandleExit(ot)
panic(0xcafe0000)
})
@@ -56,24 +56,38 @@ func TestHandleExit(t *testing.T) {
t.Errorf("Fail was never called")
}
}()
- defer handleExit(ot, false)
+ defer handleExitNew(ot)
panic(0xcafe0000)
})
})
t.Run("nil", func(t *testing.T) {
- defer handleExit(t, true)
+ defer stub.HandleExit(t)
})
t.Run("passthrough", func(t *testing.T) {
- defer func() {
- want := 0xcafebabe
- if r := recover(); r != want {
- t.Errorf("recover: %v, want %v", r, want)
- }
+ t.Run("toplevel", func(t *testing.T) {
+ defer func() {
+ want := 0xcafebabe
+ if r := recover(); r != want {
+ t.Errorf("recover: %v, want %v", r, want)
+ }
+
+ }()
+ defer stub.HandleExit(t)
+ panic(0xcafebabe)
+ })
- }()
- defer handleExit(t, true)
- panic(0xcafebabe)
+ t.Run("new", func(t *testing.T) {
+ defer func() {
+ want := 0xcafe
+ if r := recover(); r != want {
+ t.Errorf("recover: %v, want %v", r, want)
+ }
+
+ }()
+ defer handleExitNew(t)
+ panic(0xcafe)
+ })
})
}