Skip to content

Commit 0592931

Browse files
committed
fix: resolve issues with --show-skipped and --show-incomplete flags
1 parent f9fa0b9 commit 0592931

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/console_results.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,17 @@ function console_results::print_skipped_tests_and_reset() {
307307
local total_skipped
308308
total_skipped=$(state::get_tests_skipped)
309309

310+
if env::is_simple_output_enabled; then
311+
printf "\n"
312+
fi
313+
310314
if [[ "$total_skipped" -eq 1 ]]; then
311315
echo -e "${_COLOR_BOLD}There was 1 skipped test:${_COLOR_DEFAULT}\n"
312316
else
313317
echo -e "${_COLOR_BOLD}There were $total_skipped skipped tests:${_COLOR_DEFAULT}\n"
314318
fi
315319

316-
sed '${/^$/d;}' "$SKIPPED_OUTPUT_PATH" | sed 's/^/|/'
320+
tr -d '\r' < "$SKIPPED_OUTPUT_PATH" | sed '/^[[:space:]]*$/d' | sed 's/^/|/'
317321
rm "$SKIPPED_OUTPUT_PATH"
318322

319323
echo ""
@@ -325,13 +329,17 @@ function console_results::print_incomplete_tests_and_reset() {
325329
local total_incomplete
326330
total_incomplete=$(state::get_tests_incomplete)
327331

332+
if env::is_simple_output_enabled; then
333+
printf "\n"
334+
fi
335+
328336
if [[ "$total_incomplete" -eq 1 ]]; then
329337
echo -e "${_COLOR_BOLD}There was 1 incomplete test:${_COLOR_DEFAULT}\n"
330338
else
331339
echo -e "${_COLOR_BOLD}There were $total_incomplete incomplete tests:${_COLOR_DEFAULT}\n"
332340
fi
333341

334-
sed '${/^$/d;}' "$INCOMPLETE_OUTPUT_PATH" | sed 's/^/|/'
342+
tr -d '\r' < "$INCOMPLETE_OUTPUT_PATH" | sed '/^[[:space:]]*$/d' | sed 's/^/|/'
335343
rm "$INCOMPLETE_OUTPUT_PATH"
336344

337345
echo ""

src/main.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ function main::cmd_test() {
6767
exit 0
6868
;;
6969
--show-skipped)
70-
export BASHUNIT_SHOW_SKIPPED=true
70+
BASHUNIT_SHOW_SKIPPED=true
7171
;;
7272
--show-incomplete)
73-
export BASHUNIT_SHOW_INCOMPLETE=true
73+
BASHUNIT_SHOW_INCOMPLETE=true
7474
;;
7575
*)
7676
raw_args+=("$1")

src/runner.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function runner::load_test_files() {
6565
parallel::aggregate_test_results "$TEMP_DIR_PARALLEL_TEST_SUITE"
6666
# Kill the spinner once the aggregation finishes
6767
disown "$spinner_pid" && kill "$spinner_pid" &>/dev/null
68-
printf "\r " # Clear the spinner output
68+
printf "\r \r" # Clear the spinner output
6969
for script_id in "${scripts_ids[@]}"; do
7070
export BASHUNIT_CURRENT_SCRIPT_ID="${script_id}"
7171
cleanup_script_temp_files
@@ -111,6 +111,13 @@ function runner::load_bench_files() {
111111
}
112112

113113
function runner::spinner() {
114+
# Only show spinner when output is to a terminal
115+
if [[ ! -t 1 ]]; then
116+
# Not a terminal, just wait silently
117+
while true; do sleep 1; done
118+
return
119+
fi
120+
114121
if env::is_simple_output_enabled; then
115122
printf "\n"
116123
fi

0 commit comments

Comments
 (0)