-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support t.Parallel? #16
Comments
Got hit by the same issue, is there any reason not to add |
/cc @prashantv |
I think adding I don't think we can support goroutine verification in parallel tests though, since goleak verified all running goroutines, and in parallel tests, the end of a single test may still have many other goroutines running from other tests. |
@prashantv Thanks for the polite answer. I totally agreed with your thought. |
I think that's reasonable and the behavior should probably be documented :) In our cases, the tests we run in parallel don't create extra go routines at all, so goleak should still be able to handle it. That said, I think our use-case is probably a pretty restricted edge-case ;) |
Is t.Parrallel() something reasonable as a feature request though? It would be really nice to join forces to finally have solution to this: detection of leak go routines and parallel tests. (: Related discussion: fortytw2/leaktest#4 |
I don't think there is a good solution for detecting goroutine leaks from a test when using However, there is a workaround: Use the func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
} This will verify that there's no leaks after all tests are run. |
It's a known issue that goleak is incompatible with tests being run in parallel. * uber-go#16 * uber-go#83 Unfortunately, there is no real solution to this issue. * uber-go#16 (comment) * uber-go#83 (comment) * uber-go#83 (comment) This PR at least documents the incompatibility and suggests using `VerifyTestMain` instead.
It's a known issue that goleak is incompatible with tests being run in parallel. * #16 * #83 Unfortunately, there is no real solution to this issue. * #16 (comment) * #83 (comment) * #83 (comment) This PR at least documents the incompatibility and suggests using `VerifyTestMain` instead.
Hi, thanks for providing great package :)
BTW, I saw
goleak
internal source and found belowswitch...case
:goleak/options.go
Line 118 in 1874254
But, I used
t.Parallel
func on my project testing. So,goleak
suggested:Is it the expected behavior? Or, Should I adding
goleak.IgnoreTopFunction("testing.(*T).Parallel")
todefer goleak.VerifyNoLeaks(t)
? (and, is it correct use case?)The text was updated successfully, but these errors were encountered: