Skip to content

Commit ce32d4a

Browse files
committed
Merge branch 'main' into codex/improve-test-doubles-experience
2 parents d8ced70 + 51dd91e commit ce32d4a

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Run tests
4343
shell: bash
4444
run: |
45-
./bashunit tests/${{ matrix.test_chunk }}/*_test.sh
45+
./bashunit --parallel tests/${{ matrix.test_chunk }}/*_test.sh
4646
4747
alpine:
4848
name: "On alpine-latest"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Allow interpolating arguments in data providers output
77
- Deprecate `# data_provider` in favor of `# @data_provider`
88
- Allow `assert_have_been_called_with` to check arguments of specific calls
9+
- Enable parallel tests on Windows
910

1011
## [0.19.1](https://github.com/TypedDevs/bashunit/compare/0.19.0...0.19.1) - 2025-05-23
1112

docs/command-line.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ Creates a report XML file that follows the JUnit XML format and contains informa
130130
bashunit provides an option to run each test in a separate child process, allowing you to parallelize the test execution and potentially speed up the testing process. When running in parallel mode, the execution order of tests is randomized.
131131

132132
::: warning
133-
Parallel mode is currently only supported on **macOS** and **Ubuntu**. On other
134-
systems (like Alpine Linux or Windows) the option is automatically disabled due
135-
to inconsistent results. In those environments consider using `--no-parallel`.
133+
Parallel mode is supported on **macOS**, **Ubuntu**, and **Windows**. On other
134+
systems (like Alpine Linux) the option is automatically disabled due to
135+
inconsistent results. In those environments consider using `--no-parallel`.
136136
:::
137137

138138
::: code-group

src/main.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function main::exec_tests() {
2020
trap '[[ $? -eq $EXIT_CODE_STOP_ON_FAILURE ]] && main::handle_stop_on_failure_sync' EXIT
2121

2222
if env::is_parallel_run_enabled && ! parallel::is_enabled; then
23-
printf "%sWarning: Parallel tests are working only for macOS and Ubuntu.\n" "${_COLOR_INCOMPLETE}"
24-
printf "For other OS (Linux/Alpine, Windows), --parallel is not enabled due to inconsistent results,\n"
23+
printf "%sWarning: Parallel tests are supported on macOS, Ubuntu and Windows.\n" "${_COLOR_INCOMPLETE}"
24+
printf "For other OS (like Alpine), --parallel is not enabled due to inconsistent results,\n"
2525
printf "particularly involving race conditions.%s " "${_COLOR_DEFAULT}"
2626
printf "%sFallback using --no-parallel%s\n" "${_COLOR_SKIPPED}" "${_COLOR_DEFAULT}"
2727
fi

src/parallel.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ function parallel::reset() {
8787
}
8888

8989
function parallel::is_enabled() {
90-
if env::is_parallel_run_enabled && (check_os::is_macos || check_os::is_ubuntu); then
90+
if env::is_parallel_run_enabled && \
91+
(check_os::is_macos || check_os::is_ubuntu || check_os::is_windows); then
9192
return 0
9293
fi
9394
return 1

tests/unit/parallel_test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
function tear_down() {
4+
export BASHUNIT_PARALLEL_RUN=$original_parallel_run
5+
}
6+
7+
function set_up() {
8+
original_parallel_run=$BASHUNIT_PARALLEL_RUN
9+
export BASHUNIT_PARALLEL_RUN=true
10+
}
11+
12+
function test_parallel_enabled_on_windows() {
13+
mock check_os::is_windows mock_true
14+
mock check_os::is_macos mock_false
15+
mock check_os::is_ubuntu mock_false
16+
17+
assert_successful_code "$(parallel::is_enabled)"
18+
}

tests/unit/test_doubles_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function test_spy_unsuccessful_not_called() {
160160
ps
161161

162162
assert_same \
163-
"$(console_results::print_failed_test "Unsuccessful not called" "ps" \
163+
"$(console_results::print_failed_test "Spy unsuccessful not called" "ps" \
164164
"to has been called" "0 times" \
165165
"actual" "1 times")" \
166166
"$(assert_not_called ps)"

0 commit comments

Comments
 (0)