Skip to content

feat(cli): refuse a test path that does not exist - #1276

Merged
Chemaclass merged 1 commit into
mainfrom
feat/1263-fail-on-a-missing-test-path
Aug 16, 2026
Merged

Chemaclass merged 1 commit into
mainfrom
feat/1263-fail-on-a-missing-test-path

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1263

bashunit tsets/ answered No tests found — the answer an empty selection gives — so a typo read as "your tests did not match", sending the reader after test naming, filters and the discovery glob. Per the maintainer's call on that issue, a path that is not on disk is a wrong invocation and is named before discovery runs; every genuinely-empty case keeps the convention exactly as it is.

Writing the "still says No tests found" half turned up something worse: zero files after expansion read as no path was given, so bashunit empty_dir/ fell back to BASHUNIT_DEFAULT_PATH, ran the default suite and exited 0 — a pass reported for tests the caller never asked for. test_bashunit_argument_overloads_default_path only appeared to cover that because its path did not exist either.

💡 Changes

  • A positional path that is not on disk is named and refused before anything runs; a directory with no tests, an empty --filter/--tag/--shard/--changed, and a glob the shell left unexpanded all still say No tests found
  • A path that selects nothing no longer falls back to BASHUNIT_DEFAULT_PATH
  • The error goes to stderr, matching abort_unknown_option and the unknown-suite error; that left the overload test's snapshot empty, so it captures stderr and pins the wording now

`bashunit tsets/` answered "No tests found" -- the answer an empty
selection gives -- so the natural next move was to check test naming,
filters and the discovery glob rather than the typo in front of them. A
path that is not on disk is a wrong invocation, and it is now named before
discovery runs. Everything genuinely empty keeps the answer it had: a
directory with no test files, a `--filter` or `--tag` matching nothing, an
empty `--shard`, `--changed` with no changes. A pattern the shell left
unexpanded is exempt too -- nullglob is off, so `tests/zz*_test.sh` arrives
literally and matching nothing is an empty selection; the check uses the
same `*` test find_files_recursive does, so the two cannot disagree about
what a path is.

Writing the "still says No tests found" half of that turned up a worse
one. Zero files after expansion read as "no path was given", so
load_test_files fell back to BASHUNIT_DEFAULT_PATH: `bashunit empty_dir/`
ran the DEFAULT suite and exited 0. Asking for one directory and being
handed another one's results, green, is the shape of failure this repo
cares about most, and `test_bashunit_argument_overloads_default_path` only
appeared to cover it because its path did not exist either. The fallback is
now conditional on the caller having named no path.

The error goes to stderr, where abort_unknown_option and the unknown-suite
error already put a wrong invocation. That left the snapshot for the
overload test empty, i.e. pinning nothing, so it captures stderr now.

Related #1263
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 16, 2026
@Chemaclass Chemaclass self-assigned this Aug 16, 2026
@Chemaclass
Chemaclass merged commit d060e28 into main Aug 16, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/1263-fail-on-a-missing-test-path branch August 16, 2026 11:21
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