From 3fde09c589c6e7677104fdd2974029df1c46a008 Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Wed, 17 Aug 2022 13:34:31 -0700 Subject: [PATCH] Mark VerifyNone as a test Helper --- leaks.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/leaks.go b/leaks.go index f44dc25..ace2e2b 100644 --- a/leaks.go +++ b/leaks.go @@ -69,12 +69,21 @@ func Find(options ...Option) error { return fmt.Errorf("found unexpected goroutines:\n%s", stacks) } +type testHelper interface { + Helper() +} + // VerifyNone marks the given TestingT as failed if any extra goroutines are // found by Find. This is a helper method to make it easier to integrate in // tests by doing: // // defer VerifyNone(t) func VerifyNone(t TestingT, options ...Option) { + if h, ok := t.(testHelper); ok { + // Mark this function as a test helper, if available. + h.Helper() + } + if err := Find(options...); err != nil { t.Error(err) }