From b47f84708e17573230687d6340eaeae837926660 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Tue, 14 Feb 2017 23:06:59 -0500 Subject: [PATCH 01/14] exec-test: Work around Bash 3.2.57 ERR trap bug When running under Bash 3.2.57(1)-release on macOS, the following tests would fail because `BATS_ERROR_STACK_TRACE` would be empty, and hence no information about the actual error would get printed: - one failing test - failing test with significant status - failing test file outside of BATS_CWD This is because each of these cases use `FIXTURE_ROOT/failing.bats`, and the `ERR` trap would not fire for its `eval "( exit ${STATUS:-1} )"` line. Changing it to `exit ${STATUS:-1}` produced the same effect, and changing it to `return ${STATUS:-1}` would cause the output to point to the previous line, which executes `true`. However, the correct status would be reported to the `EXIT` trap, so now we call `bats_error_trap` at the very beginning of `bats_teardown_trap`. All the existing tests now pass under Bash 3.2.57(1)-release, Bash 4.2.25(1)-release (the version from the default Ubuntu 12.04.5/Precise image on Travis CI), and Bash 4.4.12(1)-release. --- libexec/bats-exec-test | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 8f3bd510..bdce3c87 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -218,13 +218,22 @@ bats_debug_trap() { fi } +# When running under Bash 3.2.57(1)-release on macOS, the `ERR` trap may not +# always fire, but the `EXIT` trap will. For this reason we call it at the very +# beginning of `bats_teardown_trap` (the `DEBUG` trap for the call will move +# `BATS_CURRENT_STACK_TRACE` to `BATS_PREVIOUS_STACK_TRACE`) and check the value +# of `$?` before taking other actions. bats_error_trap() { - BATS_ERROR_STATUS="$?" - BATS_ERROR_STACK_TRACE=( "${BATS_PREVIOUS_STACK_TRACE[@]}" ) - trap - debug + local status="$?" + if [[ "$status" -ne '0' ]]; then + BATS_ERROR_STATUS="$status" + BATS_ERROR_STACK_TRACE=( "${BATS_PREVIOUS_STACK_TRACE[@]}" ) + trap - debug + fi } bats_teardown_trap() { + bats_error_trap trap "bats_exit_trap" exit local status=0 teardown >>"$BATS_OUT" 2>&1 || status="$?" From 525e762037acb2de3db6637c5d2855a32addd595 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Tue, 14 Feb 2017 16:22:02 -0500 Subject: [PATCH 02/14] exec-test: Refactor bats_frame_* functions Preserves existing behavior. Next step will be to take the target variable name as the second argument. --- libexec/bats-exec-test | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index bdce3c87..518c1162 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -166,28 +166,22 @@ bats_print_failed_command() { } bats_frame_lineno() { - local frame="$1" - local lineno="${frame%% *}" - echo "$lineno" + printf '%s\n' "${1%% *}" } bats_frame_function() { - local frame="$1" - local rest="${frame#* }" - local fn="${rest%% *}" - echo "$fn" + local __bff_function="${1#* }" + printf '%s\n' "${__bff_function%% *}" } bats_frame_filename() { - local frame="$1" - local rest="${frame#* }" - local filename="${rest#* }" + local __bff_filename="${1#* }" + __bff_filename="${__bff_filename#* }" - if [ "$filename" = "$BATS_TEST_SOURCE" ]; then - echo "$BATS_TEST_FILENAME" - else - echo "$filename" + if [ "$__bff_filename" = "$BATS_TEST_SOURCE" ]; then + __bff_filename="$BATS_TEST_FILENAME" fi + printf '%s\n' "$__bff_filename" } bats_extract_line() { From b2ff5349ea2fb2f4283c39fab98d1ba0d5575e03 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Tue, 14 Feb 2017 16:37:35 -0500 Subject: [PATCH 03/14] exec-test: Use printf -v in bats_frame_* functions This is part of the effort to improve performance by reducing the number of command substitutions/subshells spawned by `bats_debug_trap`. Under Bash 3.2.57(1)-release on a MacBook Pro with a 2.9GHz Intel Core i5 CPU and 8GB 1867MHz DDR3 RAM, this makes `bin/bats test/` go from: 44 tests, 0 failures real 0m7.565s user 0m3.664s sys 0m3.368s to: real 0m6.449s user 0m3.290s sys 0m2.665s --- libexec/bats-exec-test | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 518c1162..734f8745 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -114,18 +114,21 @@ bats_capture_stack_trace() { fi done - BATS_SOURCE="$(bats_frame_filename "${BATS_CURRENT_STACK_TRACE[0]}")" - BATS_LINENO="$(bats_frame_lineno "${BATS_CURRENT_STACK_TRACE[0]}")" + bats_frame_filename "${BATS_CURRENT_STACK_TRACE[0]}" 'BATS_SOURCE' + bats_frame_lineno "${BATS_CURRENT_STACK_TRACE[0]}" 'BATS_LINENO' } bats_print_stack_trace() { local frame local index=1 local count="${#@}" + local filename + local lineno for frame in "$@"; do - local filename="$(bats_trim_filename "$(bats_frame_filename "$frame")")" - local lineno="$(bats_frame_lineno "$frame")" + bats_frame_filename "$frame" 'filename' + filename="$(bats_trim_filename "$filename")" + bats_frame_lineno "$frame" 'lineno' if [ $index -eq 1 ]; then echo -n "# (" @@ -133,7 +136,8 @@ bats_print_stack_trace() { echo -n "# " fi - local fn="$(bats_frame_function "$frame")" + local fn + bats_frame_function "$frame" 'fn' if [ "$fn" != "$BATS_TEST_NAME" ]; then echo -n "from function \`$fn' " fi @@ -151,8 +155,11 @@ bats_print_stack_trace() { bats_print_failed_command() { local frame="$1" local status="$2" - local filename="$(bats_frame_filename "$frame")" - local lineno="$(bats_frame_lineno "$frame")" + local filename + local lineno + + bats_frame_filename "$frame" 'filename' + bats_frame_lineno "$frame" 'lineno' local failed_line="$(bats_extract_line "$filename" "$lineno")" local failed_command="$(bats_strip_string "$failed_line")" @@ -166,12 +173,12 @@ bats_print_failed_command() { } bats_frame_lineno() { - printf '%s\n' "${1%% *}" + printf -v "$2" '%s' "${1%% *}" } bats_frame_function() { local __bff_function="${1#* }" - printf '%s\n' "${__bff_function%% *}" + printf -v "$2" '%s' "${__bff_function%% *}" } bats_frame_filename() { @@ -181,7 +188,7 @@ bats_frame_filename() { if [ "$__bff_filename" = "$BATS_TEST_SOURCE" ]; then __bff_filename="$BATS_TEST_FILENAME" fi - printf '%s\n' "$__bff_filename" + printf -v "$2" '%s' "$__bff_filename" } bats_extract_line() { From 34bd9f875f436f4cebb154d491e9f590d6211fe2 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 09:44:09 -0500 Subject: [PATCH 04/14] exec-test: Replace `dirname` call with `%/*` --- libexec/bats-exec-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 734f8745..c9e0a7e2 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -26,7 +26,7 @@ else shift fi -BATS_TEST_DIRNAME="$(dirname "$BATS_TEST_FILENAME")" +BATS_TEST_DIRNAME="${BATS_TEST_FILENAME%/*}" BATS_TEST_NAMES=() load() { From 6ff7530360b633fbec4364b0f3cb9a22e94273d5 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 10:01:32 -0500 Subject: [PATCH 05/14] exec-test: Use printf -v in bats_trim_filename --- libexec/bats-exec-test | 11 ++++------- test/test_helper.bash | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index c9e0a7e2..fce77aaa 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -127,7 +127,7 @@ bats_print_stack_trace() { for frame in "$@"; do bats_frame_filename "$frame" 'filename' - filename="$(bats_trim_filename "$filename")" + bats_trim_filename "$filename" 'filename' bats_frame_lineno "$frame" 'lineno' if [ $index -eq 1 ]; then @@ -203,13 +203,10 @@ bats_strip_string() { } bats_trim_filename() { - local filename="$1" - local length="${#BATS_CWD}" - - if [ "${filename:0:length+1}" = "${BATS_CWD}/" ]; then - echo "${filename:length+1}" + if [[ "$1" =~ ^${BATS_CWD}/ ]]; then + printf -v "$2" '%s' "${1#$BATS_CWD/}" else - echo "$filename" + printf -v "$2" '%s' "$1" fi } diff --git a/test/test_helper.bash b/test/test_helper.bash index 84eee8c3..302f743a 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -1,6 +1,6 @@ fixtures() { FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1" - RELATIVE_FIXTURE_ROOT="$(bats_trim_filename "$FIXTURE_ROOT")" + bats_trim_filename "$FIXTURE_ROOT" 'RELATIVE_FIXTURE_ROOT' } setup() { From a9dec6ccc72a9756c1a8f3f7a1cab9f356fbfb1b Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 10:07:22 -0500 Subject: [PATCH 06/14] exec-test: Use printf -v in bats_strip_string --- libexec/bats-exec-test | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index fce77aaa..55f32819 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -162,8 +162,10 @@ bats_print_failed_command() { bats_frame_lineno "$frame" 'lineno' local failed_line="$(bats_extract_line "$filename" "$lineno")" - local failed_command="$(bats_strip_string "$failed_line")" - echo -n "# \`${failed_command}' " + local failed_command + + bats_strip_string "$failed_line" 'failed_command' + printf '%s' "# \`${failed_command}' " if [ $status -eq 1 ]; then echo "failed" @@ -198,8 +200,8 @@ bats_extract_line() { } bats_strip_string() { - local string="$1" - printf "%s" "$string" | sed -e "s/^[ "$'\t'"]*//" -e "s/[ "$'\t'"]*$//" + [[ "$1" =~ ^[[:space:]]*(.*)[[:space:]]*$ ]] + printf -v "$2" '%s' "${BASH_REMATCH[1]}" } bats_trim_filename() { From 274f77c2a600fb196199dab674fe3c52f2a8b7a3 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 10:13:20 -0500 Subject: [PATCH 07/14] exec-test: Replace `type -t` with `command -F` Also eliminates a subshell. --- libexec/bats-exec-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 55f32819..71ca9b06 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -289,7 +289,7 @@ bats_perform_tests() { bats_perform_test() { BATS_TEST_NAME="$1" - if [ "$(type -t "$BATS_TEST_NAME" || true)" = "function" ]; then + if declare -F "$BATS_TEST_NAME" >/dev/null; then BATS_TEST_NUMBER="$2" if [ -z "$BATS_TEST_NUMBER" ]; then echo "1..1" From ad063d53f7752466a4da2d2bfaa5cdf3c3a85a1c Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 10:26:28 -0500 Subject: [PATCH 08/14] exec-test: Use `printf -v` in bats_extract_line Also replaces `sed` invocation with a `while` loop, saving a subprocess. --- libexec/bats-exec-test | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 71ca9b06..7e86c16b 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -157,13 +157,12 @@ bats_print_failed_command() { local status="$2" local filename local lineno + local failed_line + local failed_command bats_frame_filename "$frame" 'filename' bats_frame_lineno "$frame" 'lineno' - - local failed_line="$(bats_extract_line "$filename" "$lineno")" - local failed_command - + bats_extract_line "$filename" "$lineno" 'failed_line' bats_strip_string "$failed_line" 'failed_command' printf '%s' "# \`${failed_command}' " @@ -194,9 +193,15 @@ bats_frame_filename() { } bats_extract_line() { - local filename="$1" - local lineno="$2" - sed -n "${lineno}p" "$filename" + local __bats_extract_line_line + local __bats_extract_line_index='0' + + while IFS= read -r __bats_extract_line_line; do + if [[ "$((++__bats_extract_line_index))" -eq "$2" ]]; then + printf -v "$3" '%s' "${__bats_extract_line_line%$'\r'}" + break + fi + done <"$1" } bats_strip_string() { From 18b64b5e447aaf24bbb5071c967156354816f261 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 10:44:11 -0500 Subject: [PATCH 09/14] exec-test: Invoke bats-preprocess directly Also, `bats-preprocess` now converts DOS/Windows CRLF line endings. --- libexec/bats-exec-test | 2 +- libexec/bats-preprocess | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 7e86c16b..09e8a7ff 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -327,7 +327,7 @@ BATS_OUT="${BATS_TMPNAME}.out" bats_preprocess_source() { BATS_TEST_SOURCE="${BATS_TMPNAME}.src" - { tr -d '\r' < "$BATS_TEST_FILENAME"; echo; } | bats-preprocess > "$BATS_TEST_SOURCE" + . bats-preprocess <<< "$(< "$BATS_TEST_FILENAME")"$'\n' > "$BATS_TEST_SOURCE" trap "bats_cleanup_preprocessed_source" err exit trap "bats_cleanup_preprocessed_source; exit 1" int } diff --git a/libexec/bats-preprocess b/libexec/bats-preprocess index 04297ed0..873085e6 100755 --- a/libexec/bats-preprocess +++ b/libexec/bats-preprocess @@ -34,6 +34,7 @@ index=0 pattern='^ *@test *([^ ].*) *\{ *(.*)$' while IFS= read -r line; do + line="${line//$'\r'}" let index+=1 if [[ "$line" =~ $pattern ]]; then quoted_name="${BASH_REMATCH[1]}" From ed5870e4ae4f40d68b3053694f53ca0595da678e Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 11:01:34 -0500 Subject: [PATCH 10/14] preprocess: Use printf -v in encode_name --- libexec/bats-preprocess | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libexec/bats-preprocess b/libexec/bats-preprocess index 873085e6..6cd90eb4 100755 --- a/libexec/bats-preprocess +++ b/libexec/bats-preprocess @@ -4,6 +4,7 @@ set -e encode_name() { local name="$1" local result="test_" + local hex_code if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then name="${name//_/-5f}" @@ -21,12 +22,13 @@ encode_name() { elif [[ "$char" =~ [[:alnum:]] ]]; then result+="$char" else - result+="$(printf -- "-%02x" \'"$char")" + printf -v 'hex_code' -- "-%02x" \'"$char" + result+="$hex_code" fi done fi - echo "$result" + printf -v "$2" '%s' "$result" } tests=() @@ -40,7 +42,7 @@ while IFS= read -r line; do quoted_name="${BASH_REMATCH[1]}" body="${BASH_REMATCH[2]}" name="$(eval echo "$quoted_name")" - encoded_name="$(encode_name "$name")" + encode_name "$name" 'encoded_name' tests["${#tests[@]}"]="$encoded_name" echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}" else From 2a2433aaf717191108c73064df171490e3d0d6bc Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 11:10:55 -0500 Subject: [PATCH 11/14] exec-test: Replace `|| { }` with `if [[ ]]; then` Somehow this is ever-so-slightly faster. --- libexec/bats-exec-test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 09e8a7ff..1ffc746d 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -39,10 +39,10 @@ load() { filename="$BATS_TEST_DIRNAME/${name}.bash" fi - [ -f "$filename" ] || { + if [[ ! -f "$filename" ]]; then echo "bats: $filename does not exist" >&2 exit 1 - } + fi source "${filename}" } From 5ca462c3f177476d9914fd2a012d8811d034d153 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 11:23:28 -0500 Subject: [PATCH 12/14] exec-test: Replace `caller` with `FUNCNAME`, etc. This is part of the effort to improve performance by reducing the number of command substitutions/subshells spawned by `bats_debug_trap`. Under Bash 3.2.57(1)-release on a MacBook Pro with a 2.9GHz Intel Core i5 CPU and 8GB 1867MHz DDR3 RAM, this makes `bin/bats test/` go from the following for the previous commit: 44 tests, 0 failures real 0m5.293s user 0m2.853s sys 0m2.087s to: real 0m4.319s user 0m2.559s sys 0m1.454s --- libexec/bats-exec-test | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 1ffc746d..b27a9417 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -101,16 +101,15 @@ bats_capture_stack_trace() { local teardown_pattern=" teardown $BATS_TEST_SOURCE" local frame - local index=1 + local i - while frame="$(caller "$index")"; do + for ((i=2; i != ${#FUNCNAME[@]}; ++i)); do + frame="${BASH_LINENO[$((i-1))]} ${FUNCNAME[$i]} ${BASH_SOURCE[$i]}" BATS_CURRENT_STACK_TRACE["${#BATS_CURRENT_STACK_TRACE[@]}"]="$frame" if [[ "$frame" = *"$test_pattern" || \ "$frame" = *"$setup_pattern" || \ "$frame" = *"$teardown_pattern" ]]; then break - else - let index+=1 fi done From 9b5d4c2ff0050f95cbb0d7fa731403aa7065fe26 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 12:04:03 -0500 Subject: [PATCH 13/14] preprocess: Add tests for vars, quotes in names This is in anticipation of refactoring away the `$(eval echo "$quoted_name")` command substitution. --- test/bats.bats | 14 ++++++++++++++ test/fixtures/bats/expand_var_in_test_name.bats | 3 +++ .../bats/quoted_and_unquoted_test_names.bats | 11 +++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/fixtures/bats/expand_var_in_test_name.bats create mode 100644 test/fixtures/bats/quoted_and_unquoted_test_names.bats diff --git a/test/bats.bats b/test/bats.bats index f1aff293..d959e0f2 100755 --- a/test/bats.bats +++ b/test/bats.bats @@ -262,3 +262,17 @@ fixtures bats [ $status -eq 0 ] [ "${lines[1]}" = "ok 1 loop_func" ] } + +@test "expand variables in test name" { + SUITE='test/suite' run bats "$FIXTURE_ROOT/expand_var_in_test_name.bats" + [ $status -eq 0 ] + [ "${lines[1]}" = "ok 1 test/suite: test with variable in name" ] +} + +@test "handle quoted and unquoted test names" { + run bats "$FIXTURE_ROOT/quoted_and_unquoted_test_names.bats" + [ $status -eq 0 ] + [ "${lines[1]}" = "ok 1 single-quoted name" ] + [ "${lines[2]}" = "ok 2 double-quoted name" ] + [ "${lines[3]}" = "ok 3 unquoted" ] +} diff --git a/test/fixtures/bats/expand_var_in_test_name.bats b/test/fixtures/bats/expand_var_in_test_name.bats new file mode 100644 index 00000000..8f6dec23 --- /dev/null +++ b/test/fixtures/bats/expand_var_in_test_name.bats @@ -0,0 +1,3 @@ +@test "$SUITE: test with variable in name" { + true +} diff --git a/test/fixtures/bats/quoted_and_unquoted_test_names.bats b/test/fixtures/bats/quoted_and_unquoted_test_names.bats new file mode 100644 index 00000000..706902b3 --- /dev/null +++ b/test/fixtures/bats/quoted_and_unquoted_test_names.bats @@ -0,0 +1,11 @@ +@test 'single-quoted name' { + true +} + +@test "double-quoted name" { + true +} + +@test unquoted { + true +} From 983f9b6def2247b720b1f4d475001d7b60bc2d6a Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 11:53:01 -0500 Subject: [PATCH 14/14] preprocess: Eliminate eval in subshell This is part of the effort to improve performance by reducing the number of command substitutions/subshells. Under Bash 3.2.57(1)-release on a MacBook Pro with a 2.9GHz Intel Core i5 CPU and 8GB 1867MHz DDR3 RAM, this shaves off O(0.15s) from the test suite at the previous commit, but I anticipate this effect being magnified on Windows platforms. --- libexec/bats-preprocess | 8 ++++---- test/bats.bats | 2 +- test/fixtures/bats/quoted_and_unquoted_test_names.bats | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libexec/bats-preprocess b/libexec/bats-preprocess index 6cd90eb4..30392b68 100755 --- a/libexec/bats-preprocess +++ b/libexec/bats-preprocess @@ -33,18 +33,18 @@ encode_name() { tests=() index=0 -pattern='^ *@test *([^ ].*) *\{ *(.*)$' +pattern='^ *@test +(.+) +\{ *(.*)$' while IFS= read -r line; do line="${line//$'\r'}" let index+=1 if [[ "$line" =~ $pattern ]]; then - quoted_name="${BASH_REMATCH[1]}" + name="${BASH_REMATCH[1]#[\'\"]}" + name="${name%[\'\"]}" body="${BASH_REMATCH[2]}" - name="$(eval echo "$quoted_name")" encode_name "$name" 'encoded_name' tests["${#tests[@]}"]="$encoded_name" - echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}" + echo "${encoded_name}() { bats_test_begin \"${name}\" ${index}; ${body}" else printf "%s\n" "$line" fi diff --git a/test/bats.bats b/test/bats.bats index d959e0f2..0d703979 100755 --- a/test/bats.bats +++ b/test/bats.bats @@ -274,5 +274,5 @@ fixtures bats [ $status -eq 0 ] [ "${lines[1]}" = "ok 1 single-quoted name" ] [ "${lines[2]}" = "ok 2 double-quoted name" ] - [ "${lines[3]}" = "ok 3 unquoted" ] + [ "${lines[3]}" = "ok 3 unquoted name" ] } diff --git a/test/fixtures/bats/quoted_and_unquoted_test_names.bats b/test/fixtures/bats/quoted_and_unquoted_test_names.bats index 706902b3..aa460daa 100644 --- a/test/fixtures/bats/quoted_and_unquoted_test_names.bats +++ b/test/fixtures/bats/quoted_and_unquoted_test_names.bats @@ -6,6 +6,6 @@ true } -@test unquoted { +@test unquoted name { true }