The eight Go test functions H2 added become subtests of existing tests (catalogue's state test, the bundle's state test, the views test, the process state test, the testbus bus test, the seal byte-for-byte test), and four more are folded beside them (two seal, two process watch); the two TypeScript seal tests become one, and two more TypeScript tests are folded into their neighbours. No assertion is lost. Builds: design 47 H2 §819
28 lines
472 B
Go
28 lines
472 B
Go
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()
|
|
}
|