Skip to content

log_parsers: read jest headers with a project name or .mts path - #183

Open
jayzuccarelli wants to merge 1 commit into
huggingface:mainfrom
jayzuccarelli:fix/jest-project-headers
Open

jayzuccarelli wants to merge 1 commit into
huggingface:mainfrom
jayzuccarelli:fix/jest-project-headers

Conversation

@jayzuccarelli

Copy link
Copy Markdown

With projects, jest prints each project's displayName between the
label and the path (PASS unit src/a.test.js), and its default
testMatch also runs .mts / .cts files. Neither header matched, so
those tests lost their file prefix or were filed under the previous
file. Same-named tests in different files then overwrote each other,
and names changed with jest's file order between the pre and post runs.

Summary

  • Skip an optional display name before the path in _JEST_FILE_RE, and
    accept the extensions jest's default testMatch does ([mc]?[jt]sx?),
    in both jest_parser.py and the standalone verifier.
  • New tests/test_jest_output.py runs both parsers on plain and colored
    multi-project headers and on .mts / .cts files.
  • Extends the long-line stall test with header-shaped noise; a looser
    (?:.*?\s)? version of this regex went quadratic on PASS plus
    whitespace.

Test plan

  • pytest tests/test_jest_output.py: 6 fail on main, pass here
  • pytest tests/test_jest_output.py tests/test_mocha_output.py tests/test_log_parsers_polyglot.py plus the other parser test files: 152 passed
  • ruff check . and ruff format --check .

Out of scope

  • _JEST_TARGETABLE_EXT in pr_runtime.py also lacks .mts / .cts;
    that only falls back to running the whole suite.

Prepared with AI assistance (Claude Code); I reviewed the change and ran the tests.

With `projects`, jest prints each project's displayName between the
label and the path (`PASS unit src/a.test.js`), and its default
testMatch also runs `.mts` / `.cts` files. Neither header matched, so
those tests lost their file prefix or were filed under the previous
file. Same-named tests in different files then overwrote each other,
and names changed with jest's file order between the pre and post runs.

## Summary
- Skip an optional display name before the path in `_JEST_FILE_RE`, and
  accept the extensions jest's default testMatch does (`[mc]?[jt]sx?`),
  in both `jest_parser.py` and the standalone verifier.
- New `tests/test_jest_output.py` runs both parsers on plain and colored
  multi-project headers and on `.mts` / `.cts` files.
- Extends the long-line stall test with header-shaped noise; a looser
  `(?:.*?\s)?` version of this regex went quadratic on `PASS` plus
  whitespace.

## Test plan
- [x] `pytest tests/test_jest_output.py`: 6 fail on main, pass here
- [x] `pytest tests/test_jest_output.py tests/test_mocha_output.py tests/test_log_parsers_polyglot.py` plus the other parser test files: 152 passed
- [x] `ruff check .` and `ruff format --check .`

## Out of scope
- `_JEST_TARGETABLE_EXT` in `pr_runtime.py` also lacks `.mts` / `.cts`;
  that only falls back to running the whole suite.

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.

1 participant