package testbus import ( "fmt" "testing" ) // failed is a testing.TB that keeps what a helper failed with, so the helper's own failure is read, not suffered. type failed struct { testing.TB words string } func (f *failed) Helper() {} func (f *failed) Fatalf(format string, args ...any) { f.words = fmt.Sprintf(format, args...) panic(f) } func catch(f *failed, run func()) { defer func() { if r := recover(); r != nil && r != f { panic(r) } }() run() }