Repository navigation
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
--output <format> accepts exactly one value: tap (bashunit test --help, parsed at src/main/test.sh:72). Every other machine-readable format is file-only (--report-json, --report-junit, --report-tap, --report-html).
That forces a temp file into any pipeline that wants to post-process results:
./bashunit tests/ --report-json /tmp/r.json >/dev/null && jq '.tests[]|select(.status=="failed")' /tmp/r.jsonwhen it should be:
./bashunit tests/ --output json | jq '.tests[]|select(.status=="failed")'The formats and the writers already exist; only the destination is hard-coded.
Proposal
Extend --output to text (default) | tap | json | junit.
- Non-
textformats send the report to stdout and suppress the human-readable console rendering, exactly as--output tapdoes today. - Diagnostics and errors go to stderr so the stdout stream stays parseable.
- An unknown value exits non-zero listing the valid ones (Unknown options are silently ignored: a typo'd flag runs a different suite and exits 0 #871 class of bug).
--output jsonand--report-json f.jsonin the same run are allowed and both are produced.
Where to change
src/main/test.sh:72(--outputparsing) andsrc/main/validate.sh:60(value validation).src/main/run.sh:132-150— the reporters currently take a file path; give them a stdout path, or write to/dev/stdoutconsistently.src/reports/json.sh,src/reports/junit.sh,src/reports/tap.sh.src/console/*— the suppression switch thattapalready uses.
Acceptance criteria
-
--output jsonemits a single JSON document on stdout, valid perjq . -
--output junitemits XML on stdout -
--output tapis byte-identical to today (no regression) -
--output textequals no flag - No console decoration, progress or header leaks into stdout for the machine formats
- Errors and warnings still reach stderr
- Exit codes unchanged across all formats
-
--output json --report-json f.jsonproduces both - Unknown value exits non-zero with the valid list
- Works under
--parallel(regression guard for fix(reports): every report format is empty under --parallel #1004) - Acceptance tests piping each format through a parser
Repo checklist (agent)
- TDD: RED → GREEN → REFACTOR. Write the failing test first.
- Bash 3.0+ only: no
printf -v, no+=append, nodeclare -A, no[[ ]], no${var,,}, no&>>, no${arr[-1]}. Expanding a possibly-empty array underset -uneeds${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 needexport -n, seesrc/main/test.sh:188-196for why) - validate the value in
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) - default + env var in
src/config/env.shand a documented line in.env.example --helptext in the same block it belongs to- both
completions/bashunit.bashandcompletions/_bashunit(anti-drift test feat(cli): bash and zsh completion scripts with an anti-drift test #778 fails otherwise)
- parse in
- Gates:
make sa,make lint,./bashunit tests/,./bashunit --parallel tests/. Never runshfmt -w. - Docs: update
docs/command-line.md. Editingdocs/assertions.mdinvalidates thebashunit docacceptance snapshot — regenerate it. - CHANGELOG.md: add one line under
## Unreleased. - Fixtures under
tests/acceptance/fixtures/must not end in*test.sh. - One issue = one PR.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
- StatusShow more project fieldsDone
Activity
Chemaclass commentedon Aug 11, 2026
Done in #1064 (merged).