feat(cli): --exclude-filter to skip tests by name - #1036
Merged
Conversation
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
`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.
7 tasks
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.
🤔 Background
Related #1009
Selection by name was one-directional —
--filterincludes, with no way to exclude. Tags had both--tagand--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 leadingtest_strip), so the two are symmetric--exclude-tagover--tag--filter,--tag,--shardandfile::fntargetingDesign note
The value is read from
BASHUNIT_EXCLUDE_FILTERinsideget_functions_to_runrather 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 -nper #839, verified: the flag does not leak into nested./bashunitruns.Verification
Mutation-tested: disabling the exclusion branch fails 11 tests. Green on the Bash 3.2 floor. Selection asserted through
--list(#1007).