Skip to content

pr_runtime: run mocha with --reporter spec, not --verbose - #189

Open
RizgarOzan wants to merge 1 commit into
huggingface:mainfrom
RizgarOzan:fix/mocha-reporter
Open

RizgarOzan wants to merge 1 commit into
huggingface:mainfrom
RizgarOzan:fix/mocha-reporter

Conversation

@RizgarOzan

Copy link
Copy Markdown
Contributor

Summary

  • mocha commands now get --reporter spec instead of --verbose. mocha has no --verbose flag, so mocha 10 and 11 read the next word as its value, and targeting appends the PR's test files right after it: npx mocha --verbose test/a.spec.js test/b.spec.js only runs b.spec.js.
  • A --verbose already in the saved command is dropped, and an explicit --reporter / -R is left alone. Jest still gets --verbose.

Test plan

  • Two new tests in tests/test_pipeline_pr_runtime.py: the normalize cases (npx mocha, mocha --verbose --silent, -R dot, --reporter=tap), and normalize followed by targeting with two files. Both fail on main and pass here. The old npx mocha --verbose assertion is replaced.
  • Ran the old and new commands against real mocha 10.8.2, 11.8.0 and 12.0.3. Old: 1 of 2 files runs on 10 and 11 ("1 passing"). New: both files run on all three ("2 passing").
  • uv run ruff check ., uv run ruff format --check ., the docs generator --checks.
  • Parser / verifier / pipeline test files (test_pipeline_pr_runtime, test_log_parsers*, test_mocha_output, test_jest_output, test_pr_runtime_verifier, test_grading, test_pipeline_commit_runtime, test_pipeline_cve_patches and the cargo/pytest parser files): 436 passed.
  • Full pytest -q on Windows: the same 250 failures and 81 errors as on clean main (asset mode 0o666 and symlink privilege on this machine), the failing ids are identical; the only difference is the 2 new passing tests. I couldn't run the Linux job locally.

Out of scope

  • npm test commands that call mocha through package.json don't contain mocha, so they still get no reporter flag; I didn't touch that path.

Closes #188

mocha has no --verbose option. Mocha 10 and 11 read the next word as
its value, so once targeting appends the PR's test files the first one
is swallowed: `npx mocha --verbose test/a.spec.js test/b.spec.js` only
runs b.spec.js, and with a single file mocha falls back to ./test.

I switched mocha to --reporter spec, which is its default reporter
anyway and takes a value, so the files after it stay positional. A
--verbose the bootstrap saved is dropped too, and an explicit
--reporter / -R is left alone.

Closes huggingface#188

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.

pr_runtime: mocha --verbose swallows the first targeted test file

1 participant