-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
Area: ToolingIncludes anything related to Go builds, modules etc and includes Releases & Github Workflows.Includes anything related to Go builds, modules etc and includes Releases & Github Workflows.P2Type: Internal CleanupRefactors, etcRefactors, etc
Description
Use case(s) - what problem will this feature solve?
We want timeouts in every test, so anytime an operation needs a context (even during test setup), we want to avoid code using context.Background() or context.TODO() is needed there should be something like context.WithTimeout(context.Background(), defaultTestTimeout).
Proposed Solution
Add a linter rule that makes sure whenever we use context.Background() in test, it is using WithTimeout. Something like
git grep 'context.Background()' -- "*_test.go" | not grep -v 'context.WithTimeout(context.Background()'
Alternatives Considered
Do not lint this and continue relying on reviews to catch this.
Additional Context
Prompted by #7271 (comment)
Metadata
Metadata
Assignees
Labels
Area: ToolingIncludes anything related to Go builds, modules etc and includes Releases & Github Workflows.Includes anything related to Go builds, modules etc and includes Releases & Github Workflows.P2Type: Internal CleanupRefactors, etcRefactors, etc