Adaptive test timeouts via Await#10417
Draft
stephanos wants to merge 3 commits into
Draft
Conversation
360f0fb to
8b8a010
Compare
2cffae6 to
5fb966d
Compare
8b8a010 to
2985a57
Compare
5fb966d to
d311c81
Compare
1076781 to
fa6a741
Compare
d311c81 to
e49a9ee
Compare
fa6a741 to
be3a125
Compare
e49a9ee to
66e861b
Compare
0543253 to
ee36c2f
Compare
66e861b to
58edaea
Compare
944d4e4 to
c46c348
Compare
58edaea to
0484cd8
Compare
c46c348 to
7c54cb7
Compare
d899349 to
5e71cbc
Compare
3af47cb to
530f40c
Compare
5e71cbc to
3639e99
Compare
719c74f to
996f88b
Compare
0bfea95 to
b44d21a
Compare
e8df25d to
95dae66
Compare
stephanos
commented
Jun 11, 2026
| @@ -1,71 +0,0 @@ | |||
| package await | |||
Contributor
Author
There was a problem hiding this comment.
Integrated these into require_ctx_test.go instead; that's better as they are more end-to-end
stephanos
commented
Jun 11, 2026
| // may add decorators, but an explicit different timeout fails instead of being | ||
| // silently ignored. | ||
| func New(tb testing.TB, opts ...Option) context.Context { | ||
| func For(tb testing.TB, opts ...Option) context.Context { |
Contributor
Author
There was a problem hiding this comment.
Changed to For as New wasn't quite accurate
95dae66 to
d28b928
Compare
stephanos
commented
Jun 11, 2026
d28b928 to
b097f2a
Compare
stephanos
commented
Jun 11, 2026
8368d92 to
83cc415
Compare
stephanos
commented
Jun 11, 2026
| // AttachDecorator applies decorator to the test-scoped context once for key. | ||
| // Reusing the same key is a no-op. If the test context does not exist yet, | ||
| // AttachDecorator creates it with the default timeout. | ||
| func AttachDecorator[K comparable](tb testing.TB, key K, decorator func(context.Context) context.Context) { |
Contributor
Author
There was a problem hiding this comment.
This seems better than going through For to me now
1a06d15 to
d8ee116
Compare
d8ee116 to
087fb8a
Compare
This was referenced Jun 19, 2026
087fb8a to
8bd4ba6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
Adds
testcontext.EnsureRemainingand hasawaituse it so long await calls can request additional test-scoped context time while still respecting the test context cap.Why?
Await calls can need more time than the default test context has left (esp after the environment setup). Extending the test timeout in this way allows for (1) stuck tests to fail earlier than the default test timeout and (2) legitimately longer running tests to pass without manually tweaking the test timeout.