Skip to content

Commit f3aca00

Browse files
authored
Merge pull request #581 from TypedDevs/feat/503-no-progress-option
Add --no-progress flag to suppress real-time progress display
2 parents 147d586 + 7c4f18f commit f3aca00

10 files changed

Lines changed: 161 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
- Helps debug test failures without manually capturing output
99
- Enabled by default; use `--no-output-on-failure` or `BASHUNIT_SHOW_OUTPUT_ON_FAILURE=false` to disable
1010
- New CLI options: `--show-output`, `--no-output-on-failure`
11+
- Add `--no-progress` flag to suppress real-time progress display (Issue #503)
12+
- Hides per-test output, file headers, hook messages, and spinner during execution
13+
- Shows only the final test summary
14+
- Useful for CI/CD pipelines or log-restricted environments
15+
- Can also be set via `BASHUNIT_NO_PROGRESS=true` environment variable
1116

1217
## [0.32.0](https://github.com/TypedDevs/bashunit/compare/0.31.0...0.32.0) - 2026-01-12
1318

docs/command-line.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ bashunit test tests/ --parallel --simple
6969
| `--debug [file]` | Enable shell debug mode |
7070
| `--no-output` | Suppress all output |
7171
| `--failures-only` | Only show failures |
72+
| `--no-progress` | Suppress real-time progress, show only summary |
7273
| `--show-output` | Show test output on failure (default) |
7374
| `--no-output-on-failure` | Hide test output on failure |
7475
| `--strict` | Enable strict shell mode |
@@ -260,6 +261,39 @@ bashunit test tests/ --no-output-on-failure
260261
```
261262
:::
262263

264+
### No Progress
265+
266+
> `bashunit test --no-progress`
267+
268+
Suppress real-time progress display during test execution, showing only the final summary.
269+
270+
When enabled, bashunit hides:
271+
- Per-test output (pass/fail messages or dots)
272+
- File headers ("Running tests/...")
273+
- Hook completion messages
274+
- Spinner during parallel execution
275+
276+
The final summary with test counts and results is still displayed.
277+
278+
This is useful for:
279+
- CI/CD pipelines where streaming output causes issues
280+
- Log-restricted environments
281+
- Reducing output noise when only the final result matters
282+
283+
::: code-group
284+
```bash [Example]
285+
bashunit test tests/ --no-progress
286+
```
287+
```[Output]
288+
bashunit - 0.32.0 | Tests: 10
289+
Tests: 10 passed, 10 total
290+
Assertions: 25 passed, 25 total
291+
292+
All tests passed
293+
Time taken: 1.23s
294+
```
295+
:::
296+
263297
### Strict Mode
264298

265299
> `bashunit test --strict`

docs/configuration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,23 @@ BASHUNIT_FAILURES_ONLY=true
347347
```
348348
:::
349349

350+
## No progress
351+
352+
> `BASHUNIT_NO_PROGRESS=true|false`
353+
354+
Suppress real-time progress display during test execution. `false` by default.
355+
356+
When enabled, bashunit hides per-test output, file headers, hook messages, and spinners,
357+
showing only the final summary. Useful for CI/CD pipelines or log-restricted environments.
358+
359+
Similar as using `--no-progress` option on the [command line](/command-line#no-progress).
360+
361+
::: code-group
362+
```bash [Example]
363+
BASHUNIT_NO_PROGRESS=true
364+
```
365+
:::
366+
350367
## Show output on failure
351368

352369
> `BASHUNIT_SHOW_OUTPUT_ON_FAILURE=true|false`

src/console_header.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Options:
117117
--debug [file] Enable shell debug mode
118118
--no-output Suppress all output
119119
--failures-only Only show failures (suppress passed/skipped/incomplete)
120+
--no-progress Suppress real-time progress, show only final results
120121
--show-output Show test output on failure (default: enabled)
121122
--no-output-on-failure Hide test output on failure
122123
--strict Enable strict shell mode (set -euo pipefail)

src/console_results.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ function bashunit::console_results::print_hook_completed() {
172172
return
173173
fi
174174

175+
if bashunit::env::is_no_progress_enabled; then
176+
return
177+
fi
178+
175179
if bashunit::parallel::is_enabled; then
176180
return
177181
fi

src/env.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ _BASHUNIT_DEFAULT_LOGIN_SHELL="false"
6363
_BASHUNIT_DEFAULT_FAILURES_ONLY="false"
6464
_BASHUNIT_DEFAULT_NO_COLOR="false"
6565
_BASHUNIT_DEFAULT_SHOW_OUTPUT_ON_FAILURE="true"
66+
_BASHUNIT_DEFAULT_NO_PROGRESS="false"
6667

6768
: "${BASHUNIT_PARALLEL_RUN:=${PARALLEL_RUN:=$_BASHUNIT_DEFAULT_PARALLEL_RUN}}"
6869
: "${BASHUNIT_SHOW_HEADER:=${SHOW_HEADER:=$_BASHUNIT_DEFAULT_SHOW_HEADER}}"
@@ -82,6 +83,7 @@ _BASHUNIT_DEFAULT_SHOW_OUTPUT_ON_FAILURE="true"
8283
: "${BASHUNIT_LOGIN_SHELL:=${LOGIN_SHELL:=$_BASHUNIT_DEFAULT_LOGIN_SHELL}}"
8384
: "${BASHUNIT_FAILURES_ONLY:=${FAILURES_ONLY:=$_BASHUNIT_DEFAULT_FAILURES_ONLY}}"
8485
: "${BASHUNIT_SHOW_OUTPUT_ON_FAILURE:=${SHOW_OUTPUT_ON_FAILURE:=$_BASHUNIT_DEFAULT_SHOW_OUTPUT_ON_FAILURE}}"
86+
: "${BASHUNIT_NO_PROGRESS:=${NO_PROGRESS:=$_BASHUNIT_DEFAULT_NO_PROGRESS}}"
8587
# Support NO_COLOR standard (https://no-color.org)
8688
if [[ -n "${NO_COLOR:-}" ]]; then
8789
BASHUNIT_NO_COLOR="true"
@@ -165,6 +167,10 @@ function bashunit::env::is_show_output_on_failure_enabled() {
165167
[[ "$BASHUNIT_SHOW_OUTPUT_ON_FAILURE" == "true" ]]
166168
}
167169

170+
function bashunit::env::is_no_progress_enabled() {
171+
[[ "$BASHUNIT_NO_PROGRESS" == "true" ]]
172+
}
173+
168174
function bashunit::env::is_no_color_enabled() {
169175
[[ "$BASHUNIT_NO_COLOR" == "true" ]]
170176
}

src/main.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ function bashunit::main::cmd_test() {
8888
--no-output-on-failure)
8989
export BASHUNIT_SHOW_OUTPUT_ON_FAILURE=false
9090
;;
91+
--no-progress)
92+
export BASHUNIT_NO_PROGRESS=true
93+
;;
9194
--strict)
9295
export BASHUNIT_STRICT_MODE=true
9396
;;

src/runner.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ function bashunit::runner::spinner() {
153153
return
154154
fi
155155

156+
# Don't show spinner in no-progress mode
157+
if bashunit::env::is_no_progress_enabled; then
158+
while true; do sleep 1; done
159+
return
160+
fi
161+
156162
if bashunit::env::is_simple_output_enabled; then
157163
printf "\n"
158164
fi
@@ -369,6 +375,11 @@ function bashunit::runner::render_running_file_header() {
369375
return
370376
fi
371377

378+
# Suppress file headers in no-progress mode
379+
if bashunit::env::is_no_progress_enabled; then
380+
return
381+
fi
382+
372383
if ! bashunit::env::is_simple_output_enabled; then
373384
if bashunit::env::is_verbose_enabled; then
374385
printf "\n${_BASHUNIT_COLOR_BOLD}%s${_BASHUNIT_COLOR_DEFAULT}\n" "Running $script"
@@ -1011,6 +1022,7 @@ function bashunit::runner::run_tear_down_after_script() {
10111022
# Add blank line after tests if no tear_down hook
10121023
if ! bashunit::env::is_simple_output_enabled && \
10131024
! bashunit::env::is_failures_only_enabled && \
1025+
! bashunit::env::is_no_progress_enabled && \
10141026
! bashunit::parallel::is_enabled; then
10151027
echo ""
10161028
fi
@@ -1037,6 +1049,7 @@ function bashunit::runner::run_tear_down_after_script() {
10371049
# Add blank line after tear_down output
10381050
if ! bashunit::env::is_simple_output_enabled && \
10391051
! bashunit::env::is_failures_only_enabled && \
1052+
! bashunit::env::is_no_progress_enabled && \
10401053
! bashunit::parallel::is_enabled; then
10411054
echo ""
10421055
fi

src/state.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ function bashunit::state::print_line() {
268268

269269
bashunit::state::add_test_output "[$type]$line"
270270

271+
if bashunit::env::is_no_progress_enabled; then
272+
return
273+
fi
274+
271275
if ! bashunit::env::is_simple_output_enabled; then
272276
printf "%s\n" "$line"
273277
return
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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_no_progress_suppresses_test_output_in_detailed_mode() {
9+
local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
10+
local output
11+
12+
output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1)
13+
14+
# Should NOT contain "Passed" (per-test progress output)
15+
assert_not_contains "Passed" "$output"
16+
# Should still show final summary
17+
assert_contains "Tests:" "$output"
18+
assert_contains "4 passed" "$output"
19+
}
20+
21+
function test_no_progress_suppresses_test_output_in_simple_mode() {
22+
local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
23+
local output
24+
25+
output=$(./bashunit --no-parallel --simple --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1)
26+
27+
# Should NOT contain dots for passed tests
28+
assert_not_contains "...." "$output"
29+
# Should still show final summary
30+
assert_contains "Tests:" "$output"
31+
assert_contains "4 passed" "$output"
32+
}
33+
34+
function test_no_progress_suppresses_file_headers() {
35+
local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
36+
local output
37+
38+
output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1)
39+
40+
# Should NOT contain "Running" file headers
41+
assert_not_contains "Running" "$output"
42+
}
43+
44+
function test_no_progress_shows_correct_counts_in_summary() {
45+
local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
46+
local output
47+
48+
output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1)
49+
50+
# Summary should show passed count even though progress was suppressed
51+
assert_contains "4 passed" "$output"
52+
assert_contains "4 total" "$output"
53+
}
54+
55+
function test_no_progress_still_shows_failures_in_summary() {
56+
local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
57+
local output
58+
59+
output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1) || true
60+
61+
# Should still show failure summary
62+
assert_contains "There was 1 failure" "$output"
63+
assert_contains "Tests:" "$output"
64+
}
65+
66+
function test_no_progress_via_env_variable() {
67+
local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
68+
local output
69+
70+
output=$(BASHUNIT_NO_PROGRESS=true ./bashunit --no-parallel --skip-env-file "$test_file" 2>&1)
71+
72+
assert_not_contains "Passed" "$output"
73+
assert_contains "4 passed" "$output"
74+
}

0 commit comments

Comments
 (0)