From aaa9a3719d46777c2ba3c8cecbae41140e8270cc Mon Sep 17 00:00:00 2001 From: Jacob Oaks Date: Thu, 12 Oct 2023 13:17:52 -0400 Subject: [PATCH 1/2] Document incompatibility of VerifyNone with t.Parallel It's a known issue that goleak is incompatible with tests being run in parallel. * https://github.com/uber-go/goleak/issues/16 * https://github.com/uber-go/goleak/issues/83 Unfortunately, there is no real solution to this issue. * https://github.com/uber-go/goleak/issues/16#issuecomment-575020250 * https://github.com/uber-go/goleak/issues/83#issuecomment-1487300420 * https://github.com/uber-go/goleak/issues/83#issuecomment-1755316283 This PR at least documents the incompatibility and suggests using `VerifyTestMain` instead. --- leaks.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/leaks.go b/leaks.go index 61bc92d..bc48997 100644 --- a/leaks.go +++ b/leaks.go @@ -85,6 +85,12 @@ type testHelper interface { // tests by doing: // // defer VerifyNone(t) +// +// VerifyNone is currently incompatible with t.Parallel because it cannot +// associate specific goroutines with specific tests. Thus, non-leaking +// goroutines from other tests running in parallel could fail this check. +// If you need to run tests in parallel, use [VerifyTestMain] instead, +// which will verify that no leaking goroutines exist after ALL tests finish. func VerifyNone(t TestingT, options ...Option) { opts := buildOpts(options...) var cleanup func(int) From 7a1ce0add2b1326f0a48e79c9a1c1bc31e4352c2 Mon Sep 17 00:00:00 2001 From: Jacob Oaks Date: Thu, 12 Oct 2023 13:25:11 -0400 Subject: [PATCH 2/2] Fix lint --- leaks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leaks.go b/leaks.go index bc48997..ccb50b4 100644 --- a/leaks.go +++ b/leaks.go @@ -87,7 +87,7 @@ type testHelper interface { // defer VerifyNone(t) // // VerifyNone is currently incompatible with t.Parallel because it cannot -// associate specific goroutines with specific tests. Thus, non-leaking +// associate specific goroutines with specific tests. Thus, non-leaking // goroutines from other tests running in parallel could fail this check. // If you need to run tests in parallel, use [VerifyTestMain] instead, // which will verify that no leaking goroutines exist after ALL tests finish.