Problem
On a large suite, the fastest feedback loop is "run only what my branch touched", and bashunit cannot express it. Today the options are --rerun-failed (needs a previous failing run) or a hand-rolled git diff | xargs ./bashunit, which breaks on renames, deletions and quoting.
src/helper/git.sh exists but only holds get_latest_tag, so there is no git plumbing to build on yet.
Proposal
--changed [<ref>] Run only test files changed since <ref> (default: origin/HEAD, then HEAD)
Selection set:
- Test files added or modified in
git diff --name-only --diff-filter=d <ref>...HEAD, plus uncommitted changes in the working tree and index.
- Filtered to files that match the test-file pattern and live under the given path argument.
Deleted test files are dropped (--diff-filter=d). Behaviour when not inside a git work tree, or when <ref> does not resolve: exit non-zero with a clear message rather than silently running everything (#871 class of bug).
Explicitly out of scope for this issue: mapping source changes to the tests that cover them. That needs a @covers-style annotation and should be its own issue if wanted.
Where to change
src/helper/git.sh — add bashunit::helper::git::changed_files and bashunit::helper::git::is_repo.
src/helper/discovery.sh:208 load_test_files — intersect discovery with the changed set.
src/main/test.sh, src/config/env.sh (BASHUNIT_CHANGED), .env.example.
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
On a large suite, the fastest feedback loop is "run only what my branch touched", and bashunit cannot express it. Today the options are
--rerun-failed(needs a previous failing run) or a hand-rolledgit diff | xargs ./bashunit, which breaks on renames, deletions and quoting.src/helper/git.shexists but only holdsget_latest_tag, so there is no git plumbing to build on yet.Proposal
Selection set:
git diff --name-only --diff-filter=d <ref>...HEAD, plus uncommitted changes in the working tree and index.Deleted test files are dropped (
--diff-filter=d). Behaviour when not inside a git work tree, or when<ref>does not resolve: exit non-zero with a clear message rather than silently running everything (#871 class of bug).Explicitly out of scope for this issue: mapping source changes to the tests that cover them. That needs a
@covers-style annotation and should be its own issue if wanted.Where to change
src/helper/git.sh— addbashunit::helper::git::changed_filesandbashunit::helper::git::is_repo.src/helper/discovery.sh:208load_test_files— intersect discovery with the changed set.src/main/test.sh,src/config/env.sh(BASHUNIT_CHANGED),.env.example.Acceptance criteria
--changedwith no argument diffs againstorigin/HEADwhen it resolves, otherwiseHEAD--changed maindiffs againstmain--filter/--tag(intersection)bashunit::temp_dir), not the bashunit repo itselfRepo 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.