fix(pytest): pass --version through unfiltered#2141
Open
maxmilian wants to merge 1 commit into
Open
Conversation
`rtk pytest --version` returned "Pytest: No tests collected": pytest prints its version banner and exits without a test session, so the summary parser found no count and build_pytest_summary collapsed the banner to the terse no-tests message — the real version never reached the caller. Route --version around the filter and forward pytest's output verbatim. Scope is deliberately narrow: --help/-h are intercepted by clap (they show rtk's wrapper help) and pytest's short/count version forms are version- dependent (pytest 9's bare -V runs a session), so only the unambiguous --version is treated as informational. Fixes rtk-ai#2096
698128f to
081c87b
Compare
Author
|
Note for the PR Testing Checklist: the "token savings ≥60%" item is N/A here. This is a correctness fix, not a new/compressing filter — Remaining checklist items:
Scope is deliberately narrow ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk pytest --versionreturnedPytest: No tests collectedinstead of pytest's version string. Fixes rtk pytest --version returns 'no tests collected' — wrapper consumes the flag #2096.--versionaround the output filter and forward pytest's output verbatim.Root cause
pytest --versionprints its banner and exits without running a test session, sofilter_pytest_outputfinds nopassed/failed/skippedsummary line.build_pytest_summarythen hits the all-zero-counts branch (src/cmds/python/pytest_cmd.rs:183) and returns the hardcoded"Pytest: No tests collected"— the real banner is discarded. (The reporter's "wrapper consumes the flag" hypothesis is close; the flag is forwarded, but the filter swallows the response.)Fix
In
run(), detect--versionbefore flag injection and forward the command with an identity filter (no-q/--tb=short/-rxXinjection, no compression), so pytest's output reaches the caller byte-for-byte. Honors RTK design principle #1 (Correctness over Token Savings): a flag that explicitly asks for informational output must not be reformatted into a lossy summary.Scope (deliberately narrow)
--versiononly.-V/-VVare version-dependent — pytest 9's bare-Vruns a full session, so treating it as informational would dump a raw, unfiltered test run (a regression). Encoding that fragile per-version behavior isn't worth it;--versionis the reported, unambiguous case.--help/-hare out of scope: clap intercepts them at the subcommand layer and prints rtk's own wrapper help — they never reachrun().--collect-only/--coleft untouched — already addressed by fix(pytest): handle --collect-only output correctly #925.Tests
test_version_banner_swallowed_by_filter— documents the buggy filter behavior (banner → "No tests collected").test_is_informational_flag—--versionmatches;-V,-VV,--help,-h,-v,--verbose,--collect-only, and test paths do not.cargo fmt --checkclean.Manual verification