-
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 register teardown function in VerifyTestMain #63
Comments
Thanks for the report and the PR @tisonkun. One solution is a new option that applies only to VerifyNone and VerifyTestMain.
I don't know if this is the best solution to this problem, but it's a possibility. Ref internal issue: GO-888 |
@abhinav thanks for your suggestion, I'll think of it. The solution in #65 is just what I implement for pingcap/tidb for the same purpose, it is finished out of the library. |
Is this a ticket number of uber internal issue tracker? I guess it is a golang discussion but fail to find it. |
Yeah, sorry it's an internal issue tracker link. |
@abhinav between these two suggestion, I prefer #65 . It accepts the return code so that we may skip callbacks or customize logics. Besides, |
@abhinav today I find a time to attempt the idea you proposed above about a new type opts struct {
filters []func(stack.Stack) bool
maxRetries int
maxSleep time.Duration
cleanup func(int) int
}
func Cleanup(f func(int) int) Option {
return optionFunc(func(opts *opts) {
opts.cleanup = f
})
} However, I noticed that So, I still prefer the solution in #65. If we add an option, it only takes effect for |
This adds Cleanup option which can be passed to VerifyTestMain and VerifyNone. This takes in a function that will be executed at the end of the leak verification. Internal Ref: GO-888 Fix #63 Co-authored-by: Abhinav Gupta <mail@abhinavg.net> Co-authored-by: Abhinav Gupta <abg@uber.com>
TestMain can be used for setup and teardown logic. However, VerifyTestMain calls
os.Exit
which disables to register teardown function bydefer
. cc @prashantvThe text was updated successfully, but these errors were encountered: