Repository navigation
Conversation
📊 Automated PR Analysis
SummaryFixes the pytest wrapper so that utility flags like --version, --help, and -h bypass the default test-runner argument injection and pass/fail output parsing, instead emitting raw output via a tail fallback. This follows the same passthrough pattern already used by the JVM and PHP command wrappers. Review Checklist
Linked issues: #2096 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Protocol-zero-0
left a comment
There was a problem hiding this comment.
Tested exact head f09fdc3a523330652ad4410fe8f910ba7a906ab8 against its base 5e0f92cd108fc5a985022c5eb525a401f97fa11f with real pytest 9.0.3 on Linux: 17 scenarios / 51 raw-base-head executions, identical exit codes; 14 focused pytest tests, fmt and warnings-denied clippy pass.
Requesting changes for the advertised help passthrough:
rtk pytest --helpandrtk pytest -hstill print the 11-line RTK subcommand help, not pytest's help. Clap handles them beforeis_passthrough_flagruns. The helper-only unit test misses this public CLI behavior. #4348 already addresses this overlapping CLI/runner problem; please coordinate with that work.- Using
rtk pytest -- --help(or-- -h) reaches the new helper, butfallback_tail(..., 60)returns only the last 60 of pytest's 356 help lines. The usage, positional arguments and options such as--maxfaildisappear. It also reports “output format not recognized” for an intentionally recognized utility command.
Please make the actual CLI forward pytest's help and preserve its useful help content rather than taking only its tail. Add CLI-level checks for ordinary and separator-forwarded help, comparing the usage/options with native pytest.
The repeated version query, mixed passed/fixture-error count and ordinary double-quiet successful run behave correctly on this head. A separate, inherited limitation remains in the third commit's no-summary handling: with addopts = -q, a failing test that prints 99 passed in 0.01s still renders only Pytest: 99 passed and loses the failure details (exit 1 is preserved). This is the same residual #2960 case documented in the #2963 review, not a new regression introduced here; coordinate trusted-summary parsing with #3355 when choosing the overlapping fixes.
No full-suite, historical-pytest, external-plugin or cross-platform validation in this review.
…no tests collected
f09fdc3 to
02a0066
Compare
|
@Protocol-zero-0 Rebased onto current
I've left item 3 out, since it's the inherited #2960 case. |
Protocol-zero-0
left a comment
There was a problem hiding this comment.
The two help-passthrough blockers from my earlier review are resolved on exact head 02a0066bdfc87c739d2f2ce0e75328b4f2f7a72d.
Independently checked real pytest 9.0.3 on Linux against current base f53e60337eacf9f300801c4622dc711bd56d8abb: 17 scenarios, 51 raw/base/head executions plus 14 direct-executable utility checks. Ordinary --help/-h and separator-forwarded forms now preserve all 356 help lines, including usage and --maxfail; their stdout and stderr are byte-identical to the native pytest executable with color disabled. Version, repeated version and separator-forwarded version match too. Exit codes remain aligned with native pytest across passing, failing, fixture/collection-error and empty-suite cases. Double-quiet passing tests no longer claim that no tests were collected.
18 focused parser tests, the CLI-level help argument test, fmt and warnings-denied clippy pass. No full-suite, historical-pytest, external-plugin or cross-platform validation in this review.
The inherited #2960 case where captured 99 passed masks failure details still reproduces with exit 1 preserved; this revision does not introduce it. Keep coordinating trusted-summary parsing with #3355 and the broader help work with #4348 when integrating the overlapping fixes.
Summary
rtk pytest --version(and--help/-h) was run through the pass/fail parser like a normal test run. That output has no "N passed/failed" summary line, so the parser's zero-counts fallback fired and reportedPytest: No tests collectedinstead of the actual version/help text. Follows the passthrough pattern the JVM (mvn --version) and PHP (pint/phpstan) wrappers already use: detect the utility flag, skip injecting--tb=short -q -rxX, emit raw output instead of running it throughfilter_pytest_output.Fixes rtk pytest --version returns 'no tests collected' — wrapper consumes the flag #2096.
A pytest collection/fixture error (
=== ERRORS ===section,"1 error in Xs"summary with nopassed/failed/skippedword) hit the same zero-counts fallback and was also misreported asNo tests collected. Fixed by treating=== ERRORS ===like=== FAILURES ===, recognizingerror/errorsin both summary-line forms, tracking anerrorscount, and renderingERROR <path> - <reason>lines likeFAILEDlines.A verbosity level that prints no summary line at all — e.g. rtk's injected
-qstacking with a project'saddopts = -qinto-qq— also hit the zero-counts fallback, at exit 0, despite tests having actually run and passed. pytest's own exit codes guarantee 0 only when at least one test was collected and passed, soNo tests collectedcan never be legitimate there. The existing raw-output fallback (added in 86b34df) only coveredexit_code != 0; extended the guard to trigger on any exit code except pytest's own "no tests collected" exit (5), so this case now falls back to raw output instead of asserting the impossible.Related work / overlap — please dedupe rather than review 4x
This repo already has several open, unmerged PRs touching this exact "pytest/tool-filter reports a false green" bug class in
pytest_cmd.rs— and, to be clear having now checked history, this repo does merge scoped fixes here regularly (86b34df,aba7643,ecc34d7all landed on this file). This is a backlog/dedup problem, not a "nothing gets reviewed" problem:aba7643(merged 2026-07-23, after fix(pytest): stop false 'No tests collected' on ANSI and double-quiet output #2963 was opened) already strips ANSI inrun()before parsing. fix(pytest): stop false 'No tests collected' on ANSI and double-quiet output #2963's remaining unique contribution (the double--qraw fallback) is the same fix as this commit, via a different mechanism (their PR guards on "nothing parsed", mine guards on "exit code can't be right for this message"). Maintainer's call which approach to keep.uv run pytestrewritten touv run rtk pytestwhich resolves to wrong pytest #3565 (--collect-onlyrenders asNo tests collecteddespite tests being discovered) — has PR fix(pytest): handle --collect-only output correctly #925 open (stale/conflicted since 2026-03). Not touched here; different code path.rtk pytestwith no args) — has PR fix(pytest): surface diagnostic context when no tests are collected #2006, closed without merging. Still reproduces ondevelopper the issue thread.PASS (N) FAIL (0)when a test suite fails to compile — suite-level failures excluded from the summary #3588 is the same failure class (suite-level failure rendered as a false green) but in the jest filter, a different file — not covered by this PR.guard::never_worsefix that would likely subsume all of the pytest-specific PRs listed above (including this one) once it lands.Related: #2096, #2317, #2960, #3565, #3588, #1417
Test plan
cargo test pytest_cmd— 14/14 pass, including new tests for--versionpassthrough, a pure collection error, a mixed passed/failed/error run, the double--q-at-exit-0 fallback, and the genuine no-tests-collected-at-exit-5 casecargo fmtcargo test— full suite, 0 failuresUpdate (after review)
Rebased onto current
develop, and fixed the two help-passthrough problems from the review:rtk pytest --helpand-hnever reached the wrapper, because clap answered them first.Pytestnow has#[command(disable_help_flag = true)], asPsqlandCtestdo. If fix(cli): hand -h, --help and help to the tool each subcommand wraps #4348 lands first, the attribute goes away in a rebase.fallback_tailkept only the last 60 lines and printed "output format not recognized".The rebase brought in three upstream changes to
pytest_cmd.rs: ANSI stripping inside the parser (#4465), the test duration on the summary line, anddisplay_args. The newerrorscount now sits besideduration. TheCommandsenum moved frommain.rstolib.rs.Test plan, on
02a0066b:test_pytest_help_passthrough_argsparses--help,-hand--versionthrough clap, not just the helperrtk pytest --help,-h,-- --helpand-- -hprint the same 365 lines as nativepytest --help, with exit 0 and nothing on stderr.--versionmatches too.cargo fmt --all,cargo fmt --manifest-path proxy/Cargo.toml --all --check,cargo clippy --all-targets -D warningscargo test --all: 4,885 passed, 0 failed