File tree Expand file tree Collapse file tree 6 files changed +66
-3
lines changed Expand file tree Collapse file tree 6 files changed +66
-3
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5- - Add ` --init [dir] ` option to get you started quickly
6- - Init with custom directory updates ` .env ` with ` BASHUNIT_BOOTSTRAP `
75- Fix process time always shows as 0 ms
86- Fixed terminal width detection first tput and fall back stty
97- Refactor clock optimizing the implementation used to get the time
10- - Update and optimize ` --help ` message
8+ - Add ` --init [dir] ` option to get you started quickly
9+ - Optimize ` --help ` message
10+ - Add ` --no-output ` option
1111
1212## [ 0.21.0] ( https://github.com/TypedDevs/bashunit/compare/0.20.0...0.21.0 ) - 2025-06-18
1313
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ while [[ $# -gt 0 ]]; do
9191 export BASHUNIT_REPORT_HTML=" $2 "
9292 shift
9393 ;;
94+ --no-output)
95+ export BASHUNIT_NO_OUTPUT=true
96+ ;;
9497 -vvv|--verbose)
9598 export BASHUNIT_VERBOSE=true
9699 ;;
137140# shellcheck disable=SC1090
138141[[ -f " ${BASHUNIT_BOOTSTRAP:- } " ]] && source " $BASHUNIT_BOOTSTRAP "
139142
143+ if [[ " ${BASHUNIT_NO_OUTPUT:- false} " == true ]]; then
144+ exec > /dev/null 2>&1
145+ fi
146+
140147set +eu
141148
142149# ################
Original file line number Diff line number Diff line change @@ -340,6 +340,18 @@ Duration: 48 ms
340340```
341341:::
342342
343+ ## No output
344+
345+ > ` bashunit --no-output `
346+
347+ Run tests without printing any output. Exit code will be ` 0 ` if all tests pass or ` 1 ` otherwise.
348+
349+ ::: code-group
350+ ``` bash [Example]
351+ ./bashunit tests --no-output
352+ ```
353+ :::
354+
343355## Version
344356
345357> ` bashunit --version `
@@ -426,6 +438,8 @@ Options:
426438 Run tests in parallel (default). Random execution order.
427439 -r, --report-html <file>
428440 Write test results as an HTML report.
441+ --no-output
442+ Suppress all console output; rely on exit code.
429443 -s, --simple | --detailed
430444 Choose console output style (default: detailed).
431445 -S, --stop-on-failure
Original file line number Diff line number Diff line change @@ -247,6 +247,20 @@ BASHUNIT_VERBOSE=true
247247```
248248:::
249249
250+ ## No output
251+
252+ > ` BASHUNIT_NO_OUTPUT=true|false `
253+
254+ Suppress all console output. Defaults to ` false ` .
255+
256+ Similar as using ` --no-output ` option on the [ command line] ( /command-line#no-output ) .
257+
258+ ::: code-group
259+ ``` bash [Example]
260+ BASHUNIT_NO_OUTPUT=true
261+ ```
262+ :::
263+
250264<script setup >
251265import pkg from ' ../package.json'
252266</script >
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ _DEFAULT_STOP_ON_FAILURE="false"
2828_DEFAULT_SHOW_EXECUTION_TIME=" true"
2929_DEFAULT_VERBOSE=" false"
3030_DEFAULT_BENCH_MODE=" false"
31+ _DEFAULT_NO_OUTPUT=" false"
3132
3233: " ${BASHUNIT_PARALLEL_RUN:= ${PARALLEL_RUN:= $_DEFAULT_PARALLEL_RUN } } "
3334: " ${BASHUNIT_SHOW_HEADER:= ${SHOW_HEADER:= $_DEFAULT_SHOW_HEADER } } "
@@ -37,6 +38,7 @@ _DEFAULT_BENCH_MODE="false"
3738: " ${BASHUNIT_SHOW_EXECUTION_TIME:= ${SHOW_EXECUTION_TIME:= $_DEFAULT_SHOW_EXECUTION_TIME } } "
3839: " ${BASHUNIT_VERBOSE:= ${VERBOSE:= $_DEFAULT_VERBOSE } } "
3940: " ${BASHUNIT_BENCH_MODE:= ${BENCH_MODE:= $_DEFAULT_BENCH_MODE } } "
41+ : " ${BASHUNIT_NO_OUTPUT:= ${NO_OUTPUT:= $_DEFAULT_NO_OUTPUT } } "
4042
4143function env::is_parallel_run_enabled() {
4244 [[ " $BASHUNIT_PARALLEL_RUN " == " true" ]]
@@ -74,6 +76,10 @@ function env::is_bench_mode_enabled() {
7476 [[ " $BASHUNIT_BENCH_MODE " == " true" ]]
7577}
7678
79+ function env::is_no_output_enabled() {
80+ [[ " $BASHUNIT_NO_OUTPUT " == " true" ]]
81+ }
82+
7783function env::active_internet_connection() {
7884 if ping -c 1 -W 3 google.com & > /dev/null; then
7985 return 0
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ function set_up_before_script() {
5+ TEST_ENV_FILE=" tests/acceptance/fixtures/.env.default"
6+ }
7+
8+ function test_bashunit_no_output_success() {
9+ local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
10+ local output
11+ output=$( ./bashunit --no-parallel --env " $TEST_ENV_FILE " " $test_file " --no-output)
12+ assert_successful_code " $output "
13+ assert_empty " $output "
14+ }
15+
16+ function test_bashunit_no_output_failure() {
17+ local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
18+ local output
19+ output=$( ./bashunit --no-parallel --env " $TEST_ENV_FILE " " $test_file " --no-output)
20+ assert_general_error " $output "
21+ assert_empty " $output "
22+ }
You can’t perform that action at this time.
0 commit comments