Comments (7)
I think adding testing.(*T).Parallel
is reasonable for ignoring tests that are queued to be run later.
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.
from goleak.
I don't think there is a good solution for detecting goroutine leaks from a test when using t.Parallel
since it's intentionally running with other tests which will definitely have their own running goroutines, and we cannot identify which goroutines are started by which test.
However, there is a workaround: Use the TestMain
integration in the package,
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
This will verify that there's no leaks after all tests are run.
from goleak.
Got hit by the same issue, is there any reason not to add t.Parallel
to the whitelist?
from goleak.
/cc @prashantv
from goleak.
@prashantv Thanks for the polite answer. I totally agreed with your thought.
I wait for merge #25 pull request :D
from goleak.
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 ;)
from goleak.
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
from goleak.
Related Issues (20)
- [question]I'm literally confused about the result, why the test failed? HOT 2
- Is these function in testing package should be filtered in default? HOT 3
- goleak.IgnoreAnyFunction not working for rollbar-go
- default ignorelist entry for rules_go SIGTERM handler HOT 6
- Goleak detects leaked goroutines from other tests HOT 3
- Consider use of t.Cleanup in goleak
- Global way to ignore known leaks from a set of tests HOT 1
- 这个示例经测试,未能检测出泄漏 HOT 1
- fix security issue HOT 1
- support register teardown function in VerifyTestMain HOT 6
- Running tests with `-trace` is failing for new versions of go HOT 2
- Support tracebackancestors? HOT 1
- Friction for tinygo users
- Using goleak on Go benchmarks. HOT 1
- goleak finds goroutine leak in not enabled test case HOT 4
- goleak is no longer compatible with Go 1.5+ HOT 2
- unexpected goroutines when `ReadAll(response.body)` - false positive? HOT 4
- Please drop unmaintained golang.org/x/lint dependency from go.mod HOT 1
- Make `maxRetries` and `maxSleep` configurable in goleak HOT 9
- create v1.2.1 release
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goleak.