Skip to content

fix: check --fail-zero once for the whole run in parallel mode - #6433

Open
ShaanGS wants to merge 2 commits into
mochajs:mainfrom
ShaanGS:fix/fail-zero-parallel
Open

ShaanGS wants to merge 2 commits into
mochajs:mainfrom
ShaanGS:fix/fail-zero-parallel

Conversation

@ShaanGS

@ShaanGS ShaanGS commented Oct 18, 2026

Copy link
Copy Markdown

PR Checklist

Overview

With --parallel, each worker got the failZero option and applied it to its own file. Every file where --grep matched nothing reported one failure, and the main process added those up, so the exit code was the number of such files even when the matching tests passed.

Workers no longer get failZero. Instead, the parallel runner counts the tests the workers report and fails the run at the end if there were none. It only does this when nothing else has failed, so a run where failing before hooks skipped every test keeps the same exit code as in serial mode.

Added integration tests for --grep matching tests in only some files (exit 0) and in none (exit 1, same as serial), plus unit tests for the runner.

Each worker applied --fail-zero to its own file, so every file where
--grep matched nothing added one failure to the exit code. Stop
sending failZero to workers and check the test count reported by all
workers once, at the end of the run.

Closes mochajs#4969
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ShaanGS / name: ShaanGS (bad07d3)

This branch has not been deployed

No deployments
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.

🐛 Bug: --fail-zero + --parallel + --grep always returns an exit code even though tests pass

1 participant