Problem
Selection by name is one-directional. --filter <name> includes; there is no way to exclude by name. Tags have both (--tag / --exclude-tag), names do not.
The common case is "run everything except the handful of tests matching slow_network" without going back and tagging them first. bats-core ships --negative-filter <regex> for exactly this.
Proposal
--exclude-filter <name> Skip tests whose name matches (repeatable)
- Matching semantics identical to
--filter, so the two are symmetric and predictable.
- Repeatable; a test is skipped if it matches any
--exclude-filter.
- Exclusion wins over inclusion, mirroring how
--exclude-tag beats --tag.
- Works together with
--tag, --shard, --rerun-failed.
Where to change
src/helper/discovery.sh:62 get_functions_to_run — the include decision is made here.
src/main/test.sh flag parsing, src/config/env.sh for BASHUNIT_EXCLUDE_FILTER.
Acceptance criteria
Repo checklist (agent)
- TDD: RED → GREEN → REFACTOR. Write the failing test first.
- Bash 3.0+ only: no
printf -v, no += append, no declare -A, no [[ ]], no ${var,,}, no &>>, no ${arr[-1]}. Expanding a possibly-empty array under set -u needs ${arr[@]+"${arr[@]}"}.
- A new CLI flag must be wired in all of these or a parity test fails:
- Gates:
make sa, make lint, ./bashunit tests/, ./bashunit --parallel tests/. Never run shfmt -w.
- Docs: update
docs/command-line.md. Editing docs/assertions.md invalidates the bashunit doc acceptance snapshot — regenerate it.
- CHANGELOG.md: add one line under
## Unreleased.
- Fixtures under
tests/acceptance/fixtures/ must not end in *test.sh.
- One issue = one PR.
Problem
Selection by name is one-directional.
--filter <name>includes; there is no way to exclude by name. Tags have both (--tag/--exclude-tag), names do not.The common case is "run everything except the handful of tests matching
slow_network" without going back and tagging them first. bats-core ships--negative-filter <regex>for exactly this.Proposal
--filter, so the two are symmetric and predictable.--exclude-filter.--exclude-tagbeats--tag.--tag,--shard,--rerun-failed.Where to change
src/helper/discovery.sh:62get_functions_to_run— the include decision is made here.src/main/test.shflag parsing,src/config/env.shforBASHUNIT_EXCLUDE_FILTER.Acceptance criteria
--exclude-filter fooruns every test except those matchingfoo--filter user --exclude-filter adminruns user tests that are not admin tests--exclude-filterflags are OR'd--filterand--exclude-filter--exclude-tag)file::fnandfile:LINEtargetingtests/unit/helper/discovery_test.shplus an acceptance testRepo checklist (agent)
printf -v, no+=append, nodeclare -A, no[[ ]], no${var,,}, no&>>, no${arr[-1]}. Expanding a possibly-empty array underset -uneeds${arr[@]+"${arr[@]}"}.src/main/test.sh(report-style flags needexport -n, seesrc/main/test.sh:188-196for why)bashunit::main::validate_config_or_exit(src/main/validate.sh:60) — unvalidated input used to run the wrong thing and exit 0 (Unknown options are silently ignored: a typo'd flag runs a different suite and exits 0 #871, --jobs with a non-integer value hangs on Bash 3.x and is silently ignored on Bash 4.3+ #873)src/config/env.shand a documented line in.env.example--helptext in the same block it belongs tocompletions/bashunit.bashandcompletions/_bashunit(anti-drift test feat(cli): bash and zsh completion scripts with an anti-drift test #778 fails otherwise)make sa,make lint,./bashunit tests/,./bashunit --parallel tests/. Never runshfmt -w.docs/command-line.md. Editingdocs/assertions.mdinvalidates thebashunit docacceptance snapshot — regenerate it.## Unreleased.tests/acceptance/fixtures/must not end in*test.sh.