Skip to content

Commit 8e9faeb

Browse files
committed
fix: resolve spinner output interference in parallel mode
1 parent f9fa0b9 commit 8e9faeb

2 files changed

Lines changed: 13 additions & 3 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/runner.sh

Lines changed: 3 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
@@ -117,6 +117,8 @@ function runner::spinner() {
117117

118118
local delay=0.1
119119
local spin_chars="|/-\\"
120+
# Initial delay to avoid outputting spinner char if aggregation is fast
121+
sleep "$delay"
120122
while true; do
121123
for ((i=0; i<${#spin_chars}; i++)); do
122124
printf "\r%s" "${spin_chars:$i:1}"

0 commit comments

Comments
 (0)