mirror of https://github.com/grpc/grpc-go.git
internal: move leakcheck to t.Cleanup (#4989)
This commit is contained in:
parent
23becb71f7
commit
295d7e66be
|
|
@ -97,9 +97,13 @@ func RunSubTests(t *testing.T, x interface{}) {
|
|||
}
|
||||
tfunc := getTestFunc(t, xv, methodName)
|
||||
t.Run(strings.TrimPrefix(methodName, "Test"), func(t *testing.T) {
|
||||
// Run leakcheck in t.Cleanup() to guarantee it is run even if tfunc
|
||||
// or setup uses t.Fatal().
|
||||
//
|
||||
// Note that a defer would run before t.Cleanup, so if a goroutine
|
||||
// is closed by a test's t.Cleanup, a deferred leakcheck would fail.
|
||||
t.Cleanup(func() { teardown(t) })
|
||||
setup(t)
|
||||
// defer teardown to guarantee it is run even if tfunc uses t.Fatal()
|
||||
defer teardown(t)
|
||||
tfunc(t)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue