All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m17s
Test / Hakurei (push) Successful in 3m15s
Test / Hpkg (push) Successful in 3m56s
Test / Sandbox (race detector) (push) Successful in 4m6s
Test / Hakurei (race detector) (push) Successful in 5m2s
Test / Flake checks (push) Successful in 1m24s
This enables hakurei test suite to run on 32-bit targets. Signed-off-by: Ophestra <cat@gensokyo.uk>
45 lines
699 B
Go
45 lines
699 B
Go
package stub
|
|
|
|
import "testing"
|
|
|
|
// PanicExit is a magic panic value treated as a simulated exit.
|
|
const PanicExit = 0xdead
|
|
|
|
const (
|
|
panicFailNow = 0xcafe0 + iota
|
|
panicFatal
|
|
panicFatalf
|
|
)
|
|
|
|
// HandleExit must be deferred before calling with the stub.
|
|
func HandleExit(t testing.TB) {
|
|
switch r := recover(); r {
|
|
case PanicExit:
|
|
break
|
|
|
|
case panicFailNow:
|
|
t.FailNow()
|
|
|
|
case panicFatal, panicFatalf, nil:
|
|
break
|
|
|
|
default:
|
|
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)
|
|
}
|
|
}
|