File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55- Fix typo "to has been called"
66- Add weekly downloads to the docs
7+ - Fix parallel runner
78
89## [ 0.20.0] ( https://github.com/TypedDevs/bashunit/compare/0.19.1...0.20.0 ) - 2025-06-01
910
Original file line number Diff line number Diff line change @@ -120,7 +120,9 @@ function env::print_verbose() {
120120}
121121
122122EXIT_CODE_STOP_ON_FAILURE=4
123- TEMP_DIR_PARALLEL_TEST_SUITE=" /tmp/bashunit/parallel/${_OS:- Unknown} "
123+ # Use a unique directory per run to avoid conflicts when bashunit is invoked
124+ # recursively or multiple instances are executed in parallel.
125+ TEMP_DIR_PARALLEL_TEST_SUITE=" /tmp/bashunit/parallel/${_OS:- Unknown} /$( random_str 8) "
124126TEMP_FILE_PARALLEL_STOP_ON_FAILURE=" $TEMP_DIR_PARALLEL_TEST_SUITE /.stop-on-failure"
125127TERMINAL_WIDTH=" $( env::find_terminal_width) "
126128FAILURES_OUTPUT_PATH=$( mktemp)
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ function parallel::aggregate_test_results() {
3434 local snapshot=" ${result_line##*## ASSERTIONS_SNAPSHOT=} "
3535 snapshot=" ${snapshot%%##* } " ; snapshot=${snapshot:- 0}
3636
37+ local exit_code=" ${result_line##*## TEST_EXIT_CODE=} "
38+ exit_code=" ${exit_code%%##* } " ; exit_code=${exit_code:- 0}
39+
3740 # Add to the total counts
3841 total_failed=$(( total_failed + failed))
3942 total_passed=$(( total_passed + passed))
@@ -46,6 +49,11 @@ function parallel::aggregate_test_results() {
4649 continue
4750 fi
4851
52+ if [ " ${exit_code:- 0} " -ne 0 ]; then
53+ state::add_tests_failed
54+ continue
55+ fi
56+
4957 if [ " ${snapshot:- 0} " -gt 0 ]; then
5058 state::add_tests_snapshot
5159 continue
@@ -83,6 +91,7 @@ function parallel::must_stop_on_failure() {
8391function parallel::reset() {
8492 # shellcheck disable=SC2153
8593 rm -rf " $TEMP_DIR_PARALLEL_TEST_SUITE "
94+ mkdir -p " $TEMP_DIR_PARALLEL_TEST_SUITE "
8695 [ -f " $TEMP_FILE_PARALLEL_STOP_ON_FAILURE " ] && rm " $TEMP_FILE_PARALLEL_STOP_ON_FAILURE "
8796}
8897
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ function set_up_before_script() {
4+ TEST_ENV_FILE=" tests/acceptance/fixtures/.env.default"
5+ }
6+
7+ function test_parallel_and_sequential_results_match() {
8+ local file1=tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
9+ local file2=tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
10+ local file3=tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh
11+
12+ local sequential_output
13+ sequential_output=$( ./bashunit --no-parallel --env " $TEST_ENV_FILE " " $file1 " " $file2 " " $file3 " )
14+
15+ local parallel_output
16+ parallel_output=$( ./bashunit --parallel --env " $TEST_ENV_FILE " " $file1 " " $file2 " " $file3 " )
17+
18+ local sequential_summary
19+ sequential_summary=$( echo " $sequential_output " | grep -e " Tests:" -e " Assertions:" | tr ' \n' ' ' )
20+
21+ local parallel_summary
22+ parallel_summary=$( echo " $parallel_output " | grep -e " Tests:" -e " Assertions:" | tr ' \n' ' ' )
23+
24+ assert_equals " $sequential_summary " " $parallel_summary "
25+ }
You can’t perform that action at this time.
0 commit comments