Repository navigation
feat(pkg/paralleltestctx): detect timeout contexts used through closures - #6
Merged
Merged
Conversation
ethanndickson
added a commit
to coder/coder
that referenced
this pull request
Oct 20, 2026
…ures (#31039) #31011 fixed a flake where a closure in `TestProjectSkillQueries` used the parent test's `testutil.Context` from parallel subtests. Once that deadline passed, the closure's `require.NoError` called `FailNow` on the parent `t`, which panics and takes down the whole `coderd/database` package. `paralleltestctx` only checked direct references to the context, so it missed this. coder/paralleltestctx#6 now follows calls to local closures too. This pins `paralleltestctx` to the current `main` commit, as there's no tag yet. That commit also brings in the outer variable reassignment check from coder/paralleltestctx#4 and the `x/tools` bump from coder/paralleltestctx#5. The closure check flagged the `loadPrompt` helper in `TestMediaToolResultRoundTrip`, so it now makes its own context from the subtest's `t`. The `TestGraph` and `TestRuntimeAudit` fixes for the outer variable check are the same as in #30288, so that PR only needs to repin.
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.
coder/coder#31011 fixed a flake where a parallel subtest called a closure from the parent test, and the closure used the parent's
testutil.Context. On a slow runner the deadline had already passed by the time the subtest started. The linter only checks for direct references to the context inside the subtest, so it didn't flag this.This PR follows calls to local closures, including closures that call other closures. If a closure uses a timeout context created before
t.Parallel(), calling it aftert.Parallel()is reported the same way as using the context directly.Against coder/coder
main, this flags the coder/coder#31011 case and one more inTestMediaToolResultRoundTrip, where 11 parallel subtests use the parent'sWaitShortcontext through aloadPromptclosure. It doesn't follow closures that are passed as arguments or stored in struct fields.