From 03cb6e633cd60859e24327222d86dae4c36b76f4 Mon Sep 17 00:00:00 2001 From: Jacob Oaks Date: Thu, 12 Oct 2023 13:33:00 -0400 Subject: [PATCH] Document incompatibility of VerifyNone with t.Parallel (#107) 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..ccb50b4 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)