Skip to content

Commit a4e0ea6

Browse files
committed
fix(compat): add IFS guards to assert functions and fix array expansion in runner
1 parent 197f4b2 commit a4e0ea6

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/assert.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ function assert_not_same() {
233233

234234
function assert_contains() {
235235
bashunit::assert::should_skip && return 0
236+
local IFS=$' \t\n'
236237

237238
local expected="$1"
238239
local -a actual_arr
@@ -281,6 +282,7 @@ function assert_contains_ignore_case() {
281282

282283
function assert_not_contains() {
283284
bashunit::assert::should_skip && return 0
285+
local IFS=$' \t\n'
284286

285287
local expected="$1"
286288
local -a actual_arr
@@ -303,6 +305,7 @@ function assert_not_contains() {
303305

304306
function assert_matches() {
305307
bashunit::assert::should_skip && return 0
308+
local IFS=$' \t\n'
306309

307310
local expected="$1"
308311
local -a actual_arr
@@ -325,6 +328,7 @@ function assert_matches() {
325328

326329
function assert_not_matches() {
327330
bashunit::assert::should_skip && return 0
331+
local IFS=$' \t\n'
328332

329333
local expected="$1"
330334
local -a actual_arr
@@ -528,6 +532,7 @@ function assert_command_not_found() {
528532

529533
function assert_string_starts_with() {
530534
bashunit::assert::should_skip && return 0
535+
local IFS=$' \t\n'
531536

532537
local expected="$1"
533538
local -a actual_arr
@@ -569,6 +574,7 @@ function assert_string_not_starts_with() {
569574

570575
function assert_string_ends_with() {
571576
bashunit::assert::should_skip && return 0
577+
local IFS=$' \t\n'
572578

573579
local expected="$1"
574580
local -a actual_arr
@@ -591,6 +597,7 @@ function assert_string_ends_with() {
591597

592598
function assert_string_not_ends_with() {
593599
bashunit::assert::should_skip && return 0
600+
local IFS=$' \t\n'
594601

595602
local expected="$1"
596603
local -a actual_arr

src/runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function bashunit::runner::load_bench_files() {
120120
files=("$@")
121121

122122
local bench_file
123-
for bench_file in ${files+"${files[@]}"}; do
123+
for bench_file in "${files[@]+"${files[@]}"}"; do
124124
[[ -f $bench_file ]] || continue
125125
unset BASHUNIT_CURRENT_TEST_ID
126126
export BASHUNIT_CURRENT_SCRIPT_ID="$(bashunit::helper::generate_id "${bench_file}")"

0 commit comments

Comments
 (0)