-
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
Goleak detects leaked goroutines from other tests #48
Comments
Yes, this is expected, as goleak cannot determine which test specifically is responsible for a leak, it just identifies that there is a leak when You could run the leak detection at the beginning and end of a test to ensure there were none before the test is started, func TestB(t *testing.T) {
goleak.VerifyNone(t) // ensure there's no leaks before the test starts
defer goleak.VerifyNone(t)
} You could write your own helper for this as well. |
@prashantv thanks for the clarifications, I also got a question, can we add some option for goleak to ignore set of stacks. For example func IngoreStacks(stacks ...stack.Stack) Option {
excludeIDSet := map[int]bool{}
for _, s := range stacks {
excludeIDSet[s.ID()] = true
}
return addFilter(func(s stack.Stack) bool {
return excludeIDSet[s.ID()],
})
} And with this option I could use the next options for the example above:
What do you think about this approach? :) |
This allows usage specific tests in big projects that recently started to use go-leak check. Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com> ## Motivation #48
Fixed in #49 |
Description
We've found an interesting thing during using goleak on our CI, that goleak can detect leaked goroutine from other tests.
Steps to reproduce
goleak_test.go
Expected: TestB should pass
Actual: TestB fails with error "found unexpected goroutines:"
The text was updated successfully, but these errors were encountered: