Skip to content

feat(pkg/paralleltestctx): detect timeout contexts used through closures - #6

Merged
ethanndickson merged 1 commit into
mainfrom
closure-timeout-ctx
Oct 20, 2026
Merged

ethanndickson merged 1 commit into
mainfrom
closure-timeout-ctx

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

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 after t.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 in TestMediaToolResultRoundTrip, where 11 parallel subtests use the parent's WaitShort context through a loadPrompt closure. It doesn't follow closures that are passed as arguments or stored in struct fields.

@ethanndickson
ethanndickson merged commit da5b238 into main Oct 20, 2026
3 checks passed
@ethanndickson
ethanndickson deleted the closure-timeout-ctx branch October 20, 2026 02:03
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant