Skip to content

Commit 864f38d

Browse files
committed
refactor: clarify shell mode handling in main and runner
- Add explanatory comment in main.sh for why set +euo pipefail is needed - Handle both strict and permissive modes explicitly in runner.sh
1 parent 6868701 commit 864f38d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ function bashunit::main::cmd_test() {
143143
exec >/dev/null 2>&1
144144
fi
145145

146+
# Disable strict mode for test execution to allow:
147+
# - Empty array expansion (set +u)
148+
# - Non-zero exit codes from failing tests (set +e)
149+
# - Pipe failures in test output (set +o pipefail)
146150
set +euo pipefail
147-
148-
# Execute
149151
if [[ -n "$assert_fn" ]]; then
150152
bashunit::main::exec_assert "$assert_fn" "${args[@]}"
151153
else

src/runner.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,11 @@ function bashunit::runner::run_test() {
405405
exit $setup_exit_code
406406
fi
407407
408-
# Apply strict mode setting for test execution
408+
# Apply shell mode setting for test execution
409409
if bashunit::env::is_strict_mode_enabled; then
410410
set -euo pipefail
411+
else
412+
set +euo pipefail
411413
fi
412414
413415
# 2>&1: Redirects the std-error (FD 2) to the std-output (FD 1).

0 commit comments

Comments
 (0)