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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[test_cleanup_leak] c1
  • Loading branch information
menghanl committed Nov 17, 2021
commit 089211396962c42ec979d6322264f0199e826341
7 changes: 3 additions & 4 deletions internal/grpctest/grpctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,13 @@ func RunSubTests(t *testing.T, x interface{}) {
}
tfunc := getTestFunc(t, xv, methodName)
t.Run(strings.TrimPrefix(methodName, "Test"), func(t *testing.T) {
setup(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?

// uses t.Fatal().
//
// 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.
// 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.
t.Cleanup(func() { teardown(t) })
setup(t)
tfunc(t)
})
}
Expand Down