🤔 Background
bashunit::main::cmd_test ends its option case with a catch-all that treats any unmatched argument as a test path (src/main.sh:332):
*)
raw_args[raw_args_count]="$1"
raw_args_count=$((raw_args_count + 1))
;;
Nothing checks whether the argument looks like an option, so a mistyped flag is swallowed and the run continues with different behaviour than the user asked for — and exits 0.
Observed
| Input |
Result |
bashunit --parralel |
No tests found, exit 1 |
bashunit --parralel tests/unit/math_test.sh |
exit 0, runs sequentially, no warning |
bashunit --filterr nonexistent tests/unit/math_test.sh |
exit 0, flag and its value swallowed, whole suite runs |
$ ./bashunit --parralel --definitely-not-a-flag --xyz tests/unit/math_test.sh
bashunit - 0.43.0 | Tests: 12
...
All tests passed
$ echo $?
0
No warning on stdout or stderr.
Why it matters
--parralel, --strictt, --fail-on-riskyy all degrade silently to the weaker behaviour while still reporting success. In CI that is a green build that never ran the check it was configured to run.
- The
--filter case is the worst: a typo turns "run one test" into "run everything", exit 0 either way. The docs specifically tell agents to loop on --filter, so nothing surfaces the mistake.
Suggested fix
In the catch-all, reject an argument that begins with - as an unknown option (clear message on stderr, non-zero exit) instead of filing it under test paths. The assert subcommand parses its own arguments and is unaffected.
Found while cross-checking documented flags against the parser.
🤔 Background
bashunit::main::cmd_testends its optioncasewith a catch-all that treats any unmatched argument as a test path (src/main.sh:332):Nothing checks whether the argument looks like an option, so a mistyped flag is swallowed and the run continues with different behaviour than the user asked for — and exits
0.Observed
bashunit --parralelNo tests found, exit 1bashunit --parralel tests/unit/math_test.shbashunit --filterr nonexistent tests/unit/math_test.shNo warning on stdout or stderr.
Why it matters
--parralel,--strictt,--fail-on-riskyyall degrade silently to the weaker behaviour while still reporting success. In CI that is a green build that never ran the check it was configured to run.--filtercase is the worst: a typo turns "run one test" into "run everything", exit0either way. The docs specifically tell agents to loop on--filter, so nothing surfaces the mistake.Suggested fix
In the catch-all, reject an argument that begins with
-as an unknown option (clear message on stderr, non-zero exit) instead of filing it under test paths. Theassertsubcommand parses its own arguments and is unaffected.Found while cross-checking documented flags against the parser.