container/stub: remove function call in handleExit
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m21s
Test / Hpkg (push) Successful in 4m21s
Test / Sandbox (race detector) (push) Successful in 4m44s
Test / Hakurei (race detector) (push) Successful in 5m24s
Test / Hakurei (push) Successful in 2m26s
Test / Flake checks (push) Successful in 1m36s
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m21s
Test / Hpkg (push) Successful in 4m21s
Test / Sandbox (race detector) (push) Successful in 4m44s
Test / Hakurei (race detector) (push) Successful in 5m24s
Test / Hakurei (push) Successful in 2m26s
Test / Flake checks (push) Successful in 1m36s
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>
This commit is contained in:
@@ -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 handleExit(t, true)
|
||||
panic(0xcafebabe)
|
||||
}()
|
||||
defer stub.HandleExit(t)
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user