1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-09-29 20:48:27 +02:00

exec-test: Refactor bats_frame_* functions

Preserves existing behavior. Next step will be to take the target
variable name as the second argument.
This commit is contained in:
Mike Bland 2017-02-14 16:22:02 -05:00
parent 55bf719772
commit a3396cbc89
No known key found for this signature in database
GPG Key ID: 5121C73A6E07384B

View File

@ -166,28 +166,22 @@ bats_print_failed_command() {
} }
bats_frame_lineno() { bats_frame_lineno() {
local frame="$1" printf '%s\n' "${1%% *}"
local lineno="${frame%% *}"
echo "$lineno"
} }
bats_frame_function() { bats_frame_function() {
local frame="$1" local __bff_function="${1#* }"
local rest="${frame#* }" printf '%s\n' "${__bff_function%% *}"
local fn="${rest%% *}"
echo "$fn"
} }
bats_frame_filename() { bats_frame_filename() {
local frame="$1" local __bff_filename="${1#* }"
local rest="${frame#* }" __bff_filename="${__bff_filename#* }"
local filename="${rest#* }"
if [ "$filename" = "$BATS_TEST_SOURCE" ]; then if [ "$__bff_filename" = "$BATS_TEST_SOURCE" ]; then
echo "$BATS_TEST_FILENAME" __bff_filename="$BATS_TEST_FILENAME"
else
echo "$filename"
fi fi
printf '%s\n' "$__bff_filename"
} }
bats_extract_line() { bats_extract_line() {