Comments (3)
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 VerifyNone
is run. If you had the same defer goleak.VerifyNone(t)
in TestAt
, it would detect that test as leaking too.
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.
from goleak.
@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:
defer goleak.VerifyNone(t, goleak.IngoreStacks(stack.All()...))
What do you think about this approach? :)
from goleak.
Fixed in #49
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 8
- 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.