Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Add `assert_unsuccessful_code` assertion to check for non-zero exit codes
- Fix bench tests missing test_file var
- Fix compatibility with older python versions for clock::now
- Fix `data_set` with arguments containing spaces
- Eliminated redundant `declare -F | awk` calls that were happening for every test/bench file
- Replaced tail and process with Bash parameter expansion

Expand Down
16 changes: 14 additions & 2 deletions src/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ function runner::parse_data_provider_args() {
quote_char="$char"
;;
" " | $'\t')
args+=("$current_arg")
# Only add non-empty arguments to avoid duplicates from consecutive separators
if [[ -n "$current_arg" ]]; then
args+=("$current_arg")
fi
current_arg=""
;;
*)
Expand All @@ -192,8 +195,17 @@ function runner::parse_data_provider_args() {
fi
done
args+=("$current_arg")
# Remove all trailing empty strings
while [[ ${#args[@]} -gt 0 ]]; do
local last_idx=$((${#args[@]} - 1))
if [[ -z "${args[$last_idx]}" ]]; then
unset 'args[$last_idx]'
else
break
fi
done
# Print one arg per line to stdout, base64-encoded to preserve newlines in the data
for arg in "${args[@]}"; do
for arg in "${args[@]+"${args[@]}"}"; do
encoded_arg="$(helper::encode_base64 "${arg}")"
printf '%s\n' "$encoded_arg"
done
Expand Down
21 changes: 21 additions & 0 deletions tests/functional/provider_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,24 @@ function provide_eval_gotchas() {
echo ";" ";"
echo "1;2" "1;2"
}

# @data_provider provide_single_arg_with_space
function test_single_arg_with_space_from_data_provider() {
assert_same 1 $#
assert_same "test test" "$1"
}

function provide_single_arg_with_space() {
data_set "test test"
}

# @data_provider provide_two_args_with_spaces
function test_two_args_with_spaces_from_data_provider() {
assert_same 2 $#
assert_same "first test" "$1"
assert_same "second test" "$2"
}

function provide_two_args_with_spaces() {
data_set "first test" "second test"
}
Loading