Skip to content

Test-only tech-debt cleanup: Make TestCtx use stdlib testing.Context() instead of a DIY version #7669

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

Merged
merged 1 commit into from
Aug 7, 2025
Merged
Changes from all commits
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
4 changes: 1 addition & 3 deletions base/logging_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ func NewTaskID(contextID string, taskName string) string {

// TestCtx creates a context for the given test which is also cancelled once the test has completed.
func TestCtx(t testing.TB) context.Context {
ctx, cancelCtx := context.WithCancel(context.Background())
t.Cleanup(cancelCtx)
return LogContextWith(ctx, &LogContext{TestName: t.Name()})
return LogContextWith(t.Context(), &LogContext{TestName: t.Name()})
}

// BucketCtx extends the parent context with a bucket name.
Expand Down
Loading