You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use t.Context() instead of context.Background() in tests (#4655)
## Summary
Go 1.24 added `t.Context()` / `b.Context()` which return a context
scoped to the test lifetime. This replaces all `context.Background()`
usage in tests and test helpers with the scoped alternative.
- Replace ~1000 occurrences across ~290 files
- Add `Context()` to the `TestingT` interface
- Add a ruleguard lint rule to prevent `context.Background()` in
`_test.go` files
## Test plan
Tests pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Note that the 'ctx' variable here is something that should be passed in as
205
-
an argument by the caller. We should not use context.Background() like we do in tests.
205
+
an argument by the caller. In tests, use `t.Context()` (or `b.Context()` for benchmarks) instead of `context.Background()`. This is enforced by a lint rule.
0 commit comments