From 49600a6f46d99ff35d883381670548de1f01846e Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 31 Aug 2025 23:11:25 +0900 Subject: container/stub: export stub helpers These are very useful in many packages containing relatively large amount of code making calls to difficult or impossible to stub functions. Signed-off-by: Ophestra --- container/stub/exit.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 container/stub/exit.go (limited to 'container/stub/exit.go') diff --git a/container/stub/exit.go b/container/stub/exit.go new file mode 100644 index 00000000..8d859461 --- /dev/null +++ b/container/stub/exit.go @@ -0,0 +1,15 @@ +package stub + +// PanicExit is a magic panic value treated as a simulated exit. +const PanicExit = 0xdeadbeef + +// HandleExit must be deferred before calling with the stub. +func HandleExit() { + r := recover() + if r == PanicExit { + return + } + if r != nil { + panic(r) + } +} -- cgit v1.3.1