Skip to content

feat(cli): --list / --dry-run to show which tests would run - #1034

Merged
Chemaclass merged 2 commits into
mainfrom
feat/1007-list-dry-run
Aug 9, 2026
Merged

feat(cli): --list / --dry-run to show which tests would run#1034
Chemaclass merged 2 commits into
mainfrom
feat/1007-list-dry-run

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1007

There was no way to ask bashunit which tests it would run. Every selection mechanism was only observable by executing the suite: checking --shard balance took one full run per shard, and a typo'd --filter produced "No tests found", indistinguishable from a genuinely empty suite.

💡 Changes

  • --list (alias --dry-run) prints path::function per line on stdout, count on stderr, so the list pipes into grep/fzf/a CI matrix
  • --list-format json adds name, line and tags; an unsupported format is rejected rather than silently falling back
  • Honours every selection flag. Ordering is shared with the runner via the extracted runner::order_functions_for_script, so --list --random-order --seed N cannot drift from what seed N actually executes
  • Hooks in after all filtering and before set_up_before_script, so no test body, no lifecycle hook and no report file — verified by a fixture whose hook and body both write a marker

Notes

An empty selection exits 0 — a query, not a run. A @data_provider test is listed once, by function: that id is what you can pass back to --filter.

Both mutation-tested: moving the interception after the hooks fails 11 tests, and making the listing re-derive its own order fails exactly the seed-order test. Green on the Bash 3.2 floor.

Every selection mechanism — --filter, --tag, --exclude-tag, --shard,
--random-order --seed, --rerun-failed, file::fn, file:LINE — was only
observable by actually running the suite. Checking shard balance took one
full run per shard, and a typo'd --filter was indistinguishable from a
genuinely empty suite.

--list prints `path::function` per line on stdout with the count on stderr,
so it pipes cleanly; --list-format json adds name, line and tags.
--dry-run is a shellspec-compatible alias.

The listing hooks into load_test_files after every selection step and
before render_running_file_header and set_up_before_script, so nothing runs
beyond sourcing the files. Ordering is shared with the runner via the
extracted runner::order_functions_for_script, so a listed order cannot
drift from the order that seed executes.

An empty selection exits 0: this is a query, not a run.

Closes #1007
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 9, 2026
@Chemaclass Chemaclass self-assigned this Aug 9, 2026
…red output

The seed-order test parsed result lines with `sed 's/\x1b.../'` and
`grep -oE '^. Passed:'`. Both are environment-dependent — \x1b is a GNU sed
extension, and the status glyph is multi-byte, so `.` matches a different
amount under a non-UTF-8 locale. It passed on macOS and failed on every
Linux and locale job.

The fixture now records its own execution order to a file, so the test
compares orders directly with no rendering in the path. A paired test
asserts the seed actually reorders, so the comparison cannot hold trivially.
@Chemaclass
Chemaclass merged commit 08ec598 into main Aug 9, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/1007-list-dry-run branch August 9, 2026 19:54
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