Skip to content

Commit ab46d80

Browse files
committed
ref: bashunit support bash3.0
1 parent 0ab6f6b commit ab46d80

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

bashunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function _check_bash_version() {
1717
fi
1818

1919
local major
20-
IFS=. read -r major _ _ <<< "$current_version"
20+
major=$(echo "$current_version" | cut -d. -f1)
2121

2222
if (( major < 3 )); then
2323
printf 'Bashunit requires Bash >= %s. Current version: %s\n' "$BASHUNIT_MIN_BASH_VERSION" "$current_version" >&2

src/helpers.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,16 @@ function helper::find_total_tests() {
273273
for fn_name in "${functions_to_run[@]}"; do
274274
local provider_data
275275
provider_data=()
276-
while IFS=" " read -r line; do
277-
provider_data+=("$line")
278-
done <<< "$(helper::get_provider_data "$fn_name" "$file")"
276+
local provider_output
277+
provider_output="$(helper::get_provider_data "$fn_name" "$file")"
278+
if [[ -n "$provider_output" ]]; then
279+
local line
280+
while IFS=" " read -r line; do
281+
provider_data+=("$line")
282+
done << EOF
283+
$provider_output
284+
EOF
285+
fi
279286
280287
if [[ "${#provider_data[@]}" -eq 0 ]]; then
281288
count=$((count + 1))

src/runner.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,16 @@ function runner::call_test_functions() {
192192

193193
local provider_data
194194
provider_data=()
195-
while IFS=" " read -r line; do
196-
provider_data+=("$line")
197-
done <<< "$(helper::get_provider_data "$fn_name" "$script")"
195+
local provider_output
196+
provider_output="$(helper::get_provider_data "$fn_name" "$script")"
197+
if [[ -n "$provider_output" ]]; then
198+
local line
199+
while IFS=" " read -r line; do
200+
provider_data+=("$line")
201+
done << EOF
202+
$provider_output
203+
EOF
204+
fi
198205

199206
# No data provider found
200207
if [[ "${#provider_data[@]}" -eq 0 ]]; then
@@ -207,9 +214,14 @@ function runner::call_test_functions() {
207214
for data in "${provider_data[@]}"; do
208215
local parsed_data
209216
parsed_data=()
217+
local args_output
218+
args_output="$(runner::parse_data_provider_args "$data")"
219+
local line
210220
while IFS= read -r line; do
211221
parsed_data+=( "$(helper::decode_base64 "${line}")" )
212-
done <<< "$(runner::parse_data_provider_args "$data")"
222+
done << EOF
223+
$args_output
224+
EOF
213225
runner::run_test "$script" "$fn_name" "${parsed_data[@]}"
214226
done
215227
unset fn_name

0 commit comments

Comments
 (0)