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

internal: move leakcheck to t.Cleanup #4989

Merged
merged 3 commits into from
Nov 17, 2021
Merged

Conversation

menghanl
Copy link
Contributor

RELEASE NOTES: N/A

@menghanl menghanl added the Type: Internal Cleanup Refactors, etc label Nov 16, 2021
@menghanl menghanl added this to the 1.43 release milestone Nov 16, 2021
Comment on lines 101 to 102
// Run leakcheck in t.Cleanup() to guarantee it is run even if tfunc
// uses t.Fatal().
Copy link
Member

Choose a reason for hiding this comment

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

Should this go above setup for the same reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved.

Comment on lines 104 to 106
// Note that defer doesn't work it runs before t.Cleanup, and a
// goroutine is closed in a t.Cleanup, a deferred leakcheck will
// fail.
Copy link
Member

Choose a reason for hiding this comment

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

Wording here looks strange. How about:

// Note that a defer would run before t.Cleanup, so if a goroutine is closed
// by a test's t.Cleanup, a deferred leakcheck would fail.

Or something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@dfawley dfawley assigned menghanl and unassigned dfawley Nov 16, 2021
@menghanl menghanl assigned dfawley and unassigned menghanl Nov 17, 2021
@@ -97,9 +97,13 @@ func RunSubTests(t *testing.T, x interface{}) {
}
tfunc := getTestFunc(t, xv, methodName)
t.Run(strings.TrimPrefix(methodName, "Test"), func(t *testing.T) {
// Run leakcheck in t.Cleanup() to guarantee it is run even if tfunc
Copy link
Member

Choose a reason for hiding this comment

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

tfunc or setup?

@dfawley dfawley assigned menghanl and unassigned dfawley Nov 17, 2021
@menghanl menghanl merged commit 295d7e6 into grpc:master Nov 17, 2021
@menghanl menghanl deleted the test_cleanup_leak branch November 17, 2021 20:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants