Skip to content

fix: apply filter expressions in --dry-run and make -qq silent#671

Merged
MatthewMckee4 merged 1 commit intomainfrom
fix/dry-run-filter-and-qq
Apr 11, 2026
Merged

fix: apply filter expressions in --dry-run and make -qq silent#671
MatthewMckee4 merged 1 commit intomainfrom
fix/dry-run-filter-and-qq

Conversation

@MatthewMckee4
Copy link
Copy Markdown
Member

Summary

karva test --dry-run -E <expr> printed every collected test regardless of the filter expression. The dry-run branch was calling collect_tests and print_collected_tests before FiltersetSet::new had 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 through collect_test_names so each qualified name is evaluated against an EvalContext before 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 common test(...) predicates now work as documented.

-qq was silently equivalent to -q even though Verbosity exposes quiet as ArgAction::Count and VerbosityLevel::Silent is already wired through Printer::stdout_important to disable the failure-summary stream. Verbosity::level() only checked self.quiet > 0 and returned Quiet, so Silent was unreachable. The fix mirrors the existing self.verbose match:

match self.quiet {
    0 => {}
    1 => return VerbosityLevel::Quiet,
    _ => return VerbosityLevel::Silent,
}

cli_arg() already returns "-qq" for Silent, so the flag is correctly propagated to workers via inner_cli_args without further changes.

Test Plan

  • dry_run_applies_filter_expression in crates/karva/tests/it/filterset.rs — asserts that --dry-run -E test(~alpha) against a two-test file prints only test::test_alpha and 1 tests collected.
  • qq_is_silent_not_quiet in crates/karva/tests/it/basic.rs — asserts that -qq on a failing run produces empty stdout, where the existing test_quiet_output_failing (invoked with -q) still prints the summary line.
  • just test — 826 passed, 0 failed.
  • uvx prek run -a — all hooks green.

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.
@MatthewMckee4 MatthewMckee4 added bug Something isn't working diagnostics Related to diagnostics and output of Karva cli Related to the command-line interface labels Apr 11, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 11, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 1 untouched benchmark


Comparing fix/dry-run-filter-and-qq (8e23ba2) with main (c05b0d3)

Open in CodSpeed

@MatthewMckee4 MatthewMckee4 merged commit 19ca70d into main Apr 11, 2026
11 checks passed
@MatthewMckee4 MatthewMckee4 deleted the fix/dry-run-filter-and-qq branch April 11, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli Related to the command-line interface diagnostics Related to diagnostics and output of Karva

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant