fix: apply filter expressions in --dry-run and make -qq silent#671
Merged
MatthewMckee4 merged 1 commit intomainfrom Apr 11, 2026
Merged
fix: apply filter expressions in --dry-run and make -qq silent#671MatthewMckee4 merged 1 commit intomainfrom
MatthewMckee4 merged 1 commit intomainfrom
Conversation
Dry-run previously built a FiltersetSet solely to validate user input and then printed every collected test regardless, so karva test --dry-run -E 'test(~login)' lied about which tests would run. Parse the filterset before branching and apply it in collect_test_names before printing. Verbosity::level() returned Quiet whenever self.quiet > 0, so the Silent variant was unreachable from the CLI even though -qq advertises silent output. Mirror the self.verbose match and map quiet >= 2 to Silent, which Printer already gates as disabled for the failure-summary stream.
Merging this PR will not alter performance
|
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
karva test --dry-run -E <expr>printed every collected test regardless of the filter expression. The dry-run branch was callingcollect_testsandprint_collected_testsbeforeFiltersetSet::newhad even been constructed — the parse call further down was only validating user input and then throwing the result away. This change parses the filterset first, stores it, and threads it throughcollect_test_namesso each qualified name is evaluated against anEvalContextbefore being printed. Tag filters still degrade to an empty tag set because tag metadata is a runtime Python concept and is not available at collection time, but the commontest(...)predicates now work as documented.-qqwas silently equivalent to-qeven thoughVerbosityexposesquietasArgAction::CountandVerbosityLevel::Silentis already wired throughPrinter::stdout_importantto disable the failure-summary stream.Verbosity::level()only checkedself.quiet > 0and returnedQuiet, soSilentwas unreachable. The fix mirrors the existingself.verbosematch:cli_arg()already returns"-qq"forSilent, so the flag is correctly propagated to workers viainner_cli_argswithout further changes.Test Plan
dry_run_applies_filter_expressionincrates/karva/tests/it/filterset.rs— asserts that--dry-run -E test(~alpha)against a two-test file prints onlytest::test_alphaand1 tests collected.qq_is_silent_not_quietincrates/karva/tests/it/basic.rs— asserts that-qqon a failing run produces empty stdout, where the existingtest_quiet_output_failing(invoked with-q) still prints the summary line.just test— 826 passed, 0 failed.uvx prek run -a— all hooks green.