Repository navigation
feat(cli): refuse a test path that does not exist - #1276
Merged
Merged
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #1263
bashunit tsets/answeredNo 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 toBASHUNIT_DEFAULT_PATH, ran the default suite and exited 0 — a pass reported for tests the caller never asked for.test_bashunit_argument_overloads_default_pathonly appeared to cover that because its path did not exist either.💡 Changes
--filter/--tag/--shard/--changed, and a glob the shell left unexpanded all still sayNo tests foundBASHUNIT_DEFAULT_PATHabort_unknown_optionand the unknown-suite error; that left the overload test's snapshot empty, so it captures stderr and pins the wording now