-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add Cleanup option #78
Conversation
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
Codecov Report
@@ Coverage Diff @@
## master #78 +/- ##
==========================================
+ Coverage 94.11% 94.92% +0.80%
==========================================
Files 5 5
Lines 119 138 +19
==========================================
+ Hits 112 131 +19
Misses 4 4
Partials 3 3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
options.go
Outdated
@@ -57,6 +67,18 @@ func IgnoreTopFunction(f string) Option { | |||
}) | |||
} | |||
|
|||
// Cleanup sets up a cleanup function that will be executed at the | |||
// end of the leak. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end of the leak check?
testmain.go
Outdated
opts := buildOpts(options...) | ||
|
||
if exitCode == 0 { | ||
if err := Find(options...); err != nil { | ||
if err := Find(opts); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this end up passing a opts
to Find that has teardown set to non-nil? Same for VerifyNone.
Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall but I think there are a couple maintainability improvements we could make
assert.Contains(t, err.Error(), "blockedG") | ||
assert.Contains(t, err.Error(), "created by go.uber.org/goleak.startBlockedG") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.Contains(t, err.Error(), "blockedG") | |
assert.Contains(t, err.Error(), "created by go.uber.org/goleak.startBlockedG") | |
assert.ErrorContains(t, err, "blockedG") | |
assert.ErrorContains(t, err, "created by go.uber.org/goleak.startBlockedG") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack. This doesn't look doable rn because we're using 1.7.0 testify, and ErrorContains was introduced in 1.7.1. I'll follow up with another PR to address this.
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