-
Notifications
You must be signed in to change notification settings - Fork 354
test: correct usage of goleak.IgnoreCurrent() #2557
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2557 +/- ##
==========================================
+ Coverage 77.67% 77.69% +0.02%
==========================================
Files 439 439
Lines 53526 53526
==========================================
+ Hits 41573 41580 +7
+ Misses 9358 9352 -6
+ Partials 2595 2594 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
673c807 to
a33808b
Compare
| case <-time.After(30 * time.Second): | ||
| require.Fail(t, "ungraceful server termination") | ||
| } | ||
| goleak.VerifyNone(t, goleak.IgnoreCurrent()) |
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.
this doesn't do anything at the moment
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.
Wouldn't it verify it at that point?
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.
yes but goleak.IgnoreCurrent will blindly mark every goroutine running as ignored 😓 therefore, no leaks will be found
|
|
||
| func TestCertRotation(t *testing.T) { | ||
| t.Parallel() | ||
| defer goleak.VerifyNone(t, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start")) |
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.
See #2558
tstirrat15
left a comment
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.
See comment
| }) | ||
| t.Cleanup(cleanup) | ||
| defer goleak.VerifyNone(t, goleak.IgnoreCurrent()) | ||
| defer cleanup() |
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.
The above change makes sense to me, but why did this get changed from Cleanup to defer?
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.
if I could do t.Cleanup(goleak.VerifyNone...) then i think that would be equivalent to what I did, but i can't do that because t.Cleanup expects a function signature that goleak can't provide
tstirrat15
left a comment
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
This
and this
aren't the same. 1st snippet is correct, 2nd will cause goleak.IgnoreCurrent() to run at "the wrong time" and therefore mark all goroutines as ignored.
See uber-go/goleak#137