Skip to content
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

Merged
merged 8 commits into from
Sep 6, 2022
Merged

Add Cleanup option #78

merged 8 commits into from
Sep 6, 2022

Conversation

sywhang
Copy link
Contributor

@sywhang sywhang commented Sep 3, 2022

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

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
Copy link

codecov bot commented Sep 3, 2022

Codecov Report

Merging #78 (cd5fa11) into master (2dfebe8) will increase coverage by 0.80%.
The diff coverage is 100.00%.

@@            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              
Impacted Files Coverage Δ
leaks.go 100.00% <100.00%> (ø)
options.go 100.00% <100.00%> (ø)
testmain.go 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sywhang sywhang requested a review from abhinav September 5, 2022 19:19
leaks.go Outdated Show resolved Hide resolved
leaks_test.go Outdated Show resolved Hide resolved
leaks_test.go Outdated Show resolved Hide resolved
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.
Copy link
Collaborator

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
Comment on lines 54 to 57
opts := buildOpts(options...)

if exitCode == 0 {
if err := Find(options...); err != nil {
if err := Find(opts); err != nil {
Copy link
Collaborator

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.

sywhang and others added 2 commits September 5, 2022 21:04
Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
options.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@abhinav abhinav left a 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

Comment on lines +51 to +52
assert.Contains(t, err.Error(), "blockedG")
assert.Contains(t, err.Error(), "created by go.uber.org/goleak.startBlockedG")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")

Copy link
Contributor Author

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.

testmain.go Outdated Show resolved Hide resolved
testmain.go Outdated Show resolved Hide resolved
@sywhang sywhang merged commit 704c76c into uber-go:master Sep 6, 2022
@sywhang sywhang deleted the cleanup branch September 6, 2022 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support register teardown function in VerifyTestMain
3 participants