Skip to content

feat(cli): --exclude-filter to skip tests by name - #1036

Merged
Chemaclass merged 2 commits into
mainfrom
feat/1009-exclude-filter
Aug 9, 2026
Merged

feat(cli): --exclude-filter to skip tests by name#1036
Chemaclass merged 2 commits into
mainfrom
feat/1009-exclude-filter

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1009

Selection by name was one-directional — --filter includes, with no way to exclude. Tags had both --tag and --exclude-tag; names had only the positive form, so dropping a handful of tests meant tagging them first.

💡 Changes

  • --exclude-filter <name> skips tests whose name matches, with semantics identical to --filter (including the leading test_ strip), so the two are symmetric
  • Repeatable and OR'd; exclusion wins when a name matches both, mirroring --exclude-tag over --tag
  • Excluded tests are never selected — not reported as skipped, and not counted in the header
  • Works alongside --filter, --tag, --shard and file::fn targeting

Design note

The value is read from BASHUNIT_EXCLUDE_FILTER inside get_functions_to_run rather than threaded through as a new argument. That function is reached from two places — the header count (inside a subshell) and the runner (main shell) — and passing the filter to only one of them would print a count the run then contradicts. One source, both callers.

export -n per #839, verified: the flag does not leak into nested ./bashunit runs.

Verification

Mutation-tested: disabling the exclusion branch fails 11 tests. Green on the Bash 3.2 floor. Selection asserted through --list (#1007).

Selection by name was one-directional: --filter includes, with no way to
exclude. Tags had both, names did not, so dropping a handful of tests meant
tagging them first.

Matching mirrors --filter (including the leading test_ strip), the flag is
repeatable and OR'd, and exclusion wins when a name matches both.

The value is read from BASHUNIT_EXCLUDE_FILTER inside get_functions_to_run
rather than threaded through as an argument: the header count reaches that
function from a subshell and the runner from the main shell, and passing it
to only one of them would print a count the run then contradicts. Excluded
tests are therefore never selected, not reported as skipped.

Closes #1009
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 9, 2026
@Chemaclass Chemaclass self-assigned this Aug 9, 2026
`local functions=(...)` — declaring and initialising an array in one
statement — is not supported on Bash 3.0; it stores the literal text, so the
helper received "prefix_beta prefix_gamma)" and five tests failed on the
floor while passing on 3.2 and 5.3.

The surrounding tests in this file already carry the "Bash 3.0 compatible:
separate declaration and assignment" comment; the new ones now follow it.

Extracting the exclusion match into its own function is kept: it runs inside
get_functions_to_run's `for fn in ...` loop, so its locals are __bu_-prefixed
per bash-style.md to avoid shadowing the caller's loop variable.
@Chemaclass
Chemaclass merged commit 58abe41 into main Aug 9, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/1009-exclude-filter branch August 9, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant