Skip to content

fix(runner): run file teardown after the file's tests in parallel - #1327

Merged
Chemaclass merged 1 commit into
mainfrom
fix/1320-tear-down-after-script-runs-before-tests-parallel
Aug 19, 2026
Merged

fix(runner): run file teardown after the file's tests in parallel#1327
Chemaclass merged 1 commit into
mainfrom
fix/1320-tear-down-after-script-runs-before-tests-parallel

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1320

Under --parallel the runner dispatched a file's tests as a background worker and ran tear_down_after_script in the parent on the next line, so the hook released the fixture its own tests were still reading. The same file passed sequentially and failed in parallel.

💡 Changes

  • Move the file's teardown into the worker, after the tests it wraps. call_test_functions already waits for its per-test workers, which is what makes the ordering hold.
  • Publish a hook failure as a .result payload so the parent still counts it. A failure recorded inside a worker dies with the subshell, and without this the hook error printed while the run reported All tests passed.
  • Drop the docs/ai-agents.md caveat that told authors not to release a shared fixture in the hook. It existed only to work around this.
  • Waiting on the worker from the parent was the other option. Measured here it cost 12s of 52s, all of it two slow acceptance files that define the hook and stopped overlapping. The worker-side hook keeps the suite at 52.8s.

Under --parallel the runner dispatched the file's tests as a background
worker and ran tear_down_after_script in the parent on the next line, so
the hook released the fixture its own tests were still reading. The same
file passed sequentially and failed in parallel.

Move the hook into the worker, after call_test_functions, which already
waits for its per-test workers before returning. A hook failure recorded
in a worker dies with the subshell, so publish it as a .result payload
for the aggregator to count, the way a test publishes its own.

Waiting on the worker from the parent was the other option. Measured on
this suite it cost 12s of 52s: two slow acceptance files that define the
hook stopped overlapping with anything.

Closes #1320
@Chemaclass Chemaclass added the bug Something isn't working label Aug 19, 2026
@Chemaclass Chemaclass self-assigned this Aug 19, 2026
@Chemaclass
Chemaclass merged commit f30ff74 into main Aug 19, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/1320-tear-down-after-script-runs-before-tests-parallel branch August 19, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant