diff --git a/t.go b/t.go index 7e08c4c..7faaca1 100644 --- a/t.go +++ b/t.go @@ -2,6 +2,7 @@ package justest import ( "fmt" + "testing" ) type T interface { @@ -34,3 +35,16 @@ func GetHelper(t T) interface{ Helper() } { } return &noOpHelper{} } + +//go:noinline +func GetRoot(t T) *testing.T { + for { + if hp, ok := t.(HasParent); ok { + t = hp.GetParent() + } else if rt, ok := t.(*testing.T); ok { + return rt + } else { + panic(fmt.Sprintf("unsupported T instance: %+v (%T)", t, t)) + } + } +}