You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no way to ask bashunit which tests it would run. Every selection mechanism — --filter, --tag, --exclude-tag, --shard i/n, --random-order --seed, --rerun-failed, file::fn, file:LINE — is only observable by actually running the suite.
Consequences today:
--shard 1/4 cannot be checked for balance without four full runs.
A typo'd --filter silently runs 0 tests and exits 1 with "No tests found" (src/console/summary.sh:128), indistinguishable from a genuinely empty suite.
Editor/CI tooling has no machine-readable list of test ids.
bats-core has -c/--count, shellspec has --dry-run and --list examples.
Proposal
--list Print the tests that would run, then exit 0
--list-format <fmt> text (default) | json
--dry-run Alias of --list (shellspec-compatible spelling)
Honours every selection flag, applied in the same order as a real run, including shard slicing and --random-order --seed ordering.
text output: one path/to/file_test.sh::test_function_name per line, followed by N tests on stderr.
No test body is executed, no bootstrap side effects beyond sourcing, no reports are written.
Exit code 0 even when the list is empty (this is a query, not a run).
Where to change
src/helper/discovery.sh:62get_functions_to_run and :134find_total_tests already do the selection work — the list command should reuse them rather than re-implement filtering.
src/helper/tags.sh:99function_matches_tags for the tag column.
src/helper/discovery.sh:243get_function_line_number for the line column.
src/main/run.sh — branch before the runner loop.
src/helper/naming.shnormalize_test_function_name for the human-readable name.
Acceptance criteria
bashunit --list tests/ lists every test, one per line, and exits 0
--list respects --filter, --tag, --exclude-tag, --shard, --rerun-failed, file::fn and file:LINE
--list --random-order --seed 42 prints the same order that --random-order --seed 42 would execute
--list-format json emits valid JSON (verify with jq) including file, function, name, line, tags
Data-provider tests are listed once per test function (document the choice in the docs if a provider expands to N cases)
No test body runs: a fixture whose test writes a marker file leaves no marker after --list
Empty selection prints nothing and exits 0
Acceptance test in tests/acceptance/bashunit_list_test.sh
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:
parse in src/main/test.sh (report-style flags need export -n, see src/main/test.sh:188-196 for why)
Problem
There is no way to ask bashunit which tests it would run. Every selection mechanism —
--filter,--tag,--exclude-tag,--shard i/n,--random-order --seed,--rerun-failed,file::fn,file:LINE— is only observable by actually running the suite.Consequences today:
--shard 1/4cannot be checked for balance without four full runs.--filtersilently runs 0 tests and exits 1 with "No tests found" (src/console/summary.sh:128), indistinguishable from a genuinely empty suite.bats-core has
-c/--count, shellspec has--dry-runand--list examples.Proposal
--random-order --seedordering.textoutput: onepath/to/file_test.sh::test_function_nameper line, followed byN testson stderr.jsonoutput:{"count": N, "tests": [{"file": "...", "function": "...", "name": "human readable", "line": 12, "tags": ["slow"]}]}.0even when the list is empty (this is a query, not a run).Where to change
src/helper/discovery.sh:62get_functions_to_runand:134find_total_testsalready do the selection work — the list command should reuse them rather than re-implement filtering.src/helper/tags.sh:99function_matches_tagsfor the tag column.src/helper/discovery.sh:243get_function_line_numberfor the line column.src/main/run.sh— branch before the runner loop.src/helper/naming.shnormalize_test_function_namefor the human-readable name.Acceptance criteria
bashunit --list tests/lists every test, one per line, and exits 0--listrespects--filter,--tag,--exclude-tag,--shard,--rerun-failed,file::fnandfile:LINE--list --random-order --seed 42prints the same order that--random-order --seed 42would execute--list-format jsonemits valid JSON (verify withjq) includingfile,function,name,line,tags--listtests/acceptance/bashunit_list_test.shRepo 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.