-
Notifications
You must be signed in to change notification settings - Fork 427
refactor: use testing.T.Context() instead of context.WithCancel #3775
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
base: main
Are you sure you want to change the base?
refactor: use testing.T.Context() instead of context.WithCancel #3775
Conversation
Replace manual context.WithCancel(context.Background()) pattern with t.Context() in test files. This is a mechanical refactoring that uses Go 1.21's testing.T.Context() method which automatically cancels the context when the test completes. Fixes kcp-dev#3535 Signed-off-by: majiayu000 <[email protected]>
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @majiayu000. Thanks for your PR. I'm waiting for a kcp-dev member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/ok-to-test |
|
ah, @xrstf left comment about this #3535 (comment) |
|
@majiayu000: The following tests failed, say
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
a) What @xrstf said; we can't replace it everywhere, only where cancelling isn't needed. |
|
@majiayu000 how confident you are that your pr adresses above comments ^ or was it just AI generated replace all? |
Fixes #3535
Changes
ctx, cancel := context.WithCancel(context.Background())pattern witht.Context()in test filesdefer cancel()/t.Cleanup(cancel)callsThis is a mechanical refactoring that uses Go 1.21's
testing.T.Context()method which automatically cancels the context when the test completes.