Skip to content

Add -t / --tag flag for filtering tests by custom tag expressions#422

Merged
MatthewMckee4 merged 2 commits intomainfrom
feat/tag-filtering
Feb 7, 2026
Merged

Add -t / --tag flag for filtering tests by custom tag expressions#422
MatthewMckee4 merged 2 commits intomainfrom
feat/tag-filtering

Conversation

@MatthewMckee4
Copy link
Member

@MatthewMckee4 MatthewMckee4 commented Feb 7, 2026

Summary

  • Adds -t / --tag CLI flag for filtering tests by tag expressions (closes Support custom tags #266)
  • Expressions support and, or, not, and parentheses for grouping with correct operator precedence
  • Multiple -t flags use OR semantics: a test runs if it matches any expression
  • Removes #[expect(dead_code)] from CustomTag name field and Tag::Custom variant, now that custom tags are actively read
  • Tag filter is validated early in the main process and forwarded to worker processes

Test plan

just test

…#266)

Implements tag expression filtering so users can selectively run tests
based on custom tags like `@karva.tags.slow` or `@karva.tags.integration`.
Expressions support `and`, `or`, `not`, and parentheses. Multiple `-t`
flags use OR semantics. Also removes dead_code annotations from CustomTag
fields now that they are actively used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MatthewMckee4 MatthewMckee4 added the extensions/tags Related to Karva tags or pytest marks label Feb 7, 2026
@github-actions
Copy link

github-actions bot commented Feb 7, 2026

Project Diff Results

No changes between this PR and main.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 7, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing feat/tag-filtering (cfcad5a) with main (41966b5)

Summary

✅ 1 untouched benchmark

@MatthewMckee4 MatthewMckee4 force-pushed the feat/tag-filtering branch 2 times, most recently from 32616c6 to faf5fd4 Compare February 7, 2026 01:54
…ute_test_variant` return type

Relocate the filter module from `karva_cli` to `karva_metadata` so `TestSettings`
can own the `TagFilterSet`. This removes the `tag_filter` field from `Context`,
and changes `execute_test_variant` to return `bool` instead of `Option<bool>`,
treating tag-filtered tests like skips (early return `true`).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MatthewMckee4 MatthewMckee4 merged commit e6425a5 into main Feb 7, 2026
13 checks passed
@MatthewMckee4 MatthewMckee4 deleted the feat/tag-filtering branch February 7, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions/tags Related to Karva tags or pytest marks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom tags

1 participant