You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, every call to goleak.Verify* needs to specify any stacks to ignore. If there are known leaks which affect multiple packages, this results in duplication in each package specifying the same ignores.
We should investigate approaches to make this easier, as a strawman proposal:
Add AppendDefaultOptions as an exported function that allows appending a default set of ignores, that can be called in some init function, and can be shared for all tests by depending on the package that adds the default options.
The text was updated successfully, but these errors were encountered:
Things have changed since the original strawman proposal: there's a Cleanup option, so AppendDefaultOptions might not be what we want.
We could do something like AppendKnownLeaks instead. It'll still take an Option, but panic if Cleanup is specified. And with global registration, we may want the ability to reverse the append even if we're not likely to use it.
funcAppendKnownLeaks(opts...Option) (undofunc())
That said, I'm not sure this or the original proposal will be sufficient.
Known leaks need to be ignored in all tests of a module. Tests for each package in the module run as separate binaries.
So every test package will have to remember to import _ "example.com/internal/knownleaks" to get the global leaks registered. That's not too far removed from writing an internal wrapper around goleak (import "example.com/internal/goleak") that just passes known leaks to VerifyTestMain as needed.
Do you think the global list of ignores would still be worth it?
Currently, every call to
goleak.Verify*
needs to specify any stacks to ignore. If there are known leaks which affect multiple packages, this results in duplication in each package specifying the same ignores.We should investigate approaches to make this easier, as a strawman proposal:
Add
AppendDefaultOptions
as an exported function that allows appending a default set of ignores, that can be called in someinit
function, and can be shared for all tests by depending on the package that adds the default options.The text was updated successfully, but these errors were encountered: