diff --git a/libexec/bats b/libexec/bats index 7dc0c14..e074747 100755 --- a/libexec/bats +++ b/libexec/bats @@ -77,6 +77,7 @@ abs_dirname '.' 'BATS_CWD' export BATS_PREFIX export BATS_CWD +export BATS_TEST_PATTERN='^ *@test +(.+) +\{ *(.*)$' export PATH="$BATS_LIBEXEC:$PATH" options=() diff --git a/libexec/bats-exec-suite b/libexec/bats-exec-suite index 29ab255..96021bb 100755 --- a/libexec/bats-exec-suite +++ b/libexec/bats-exec-suite @@ -17,7 +17,11 @@ trap "kill 0; exit 1" int count=0 for filename in "$@"; do - let count+="$(bats-exec-test -c "$filename")" + while IFS= read -r line; do + if [[ "$line" =~ $BATS_TEST_PATTERN ]]; then + let count+=1 + fi + done <"$filename" done if [ -n "$count_only_flag" ]; then diff --git a/libexec/bats-preprocess b/libexec/bats-preprocess index 30392b6..8307b76 100755 --- a/libexec/bats-preprocess +++ b/libexec/bats-preprocess @@ -33,12 +33,11 @@ encode_name() { tests=() index=0 -pattern='^ *@test +(.+) +\{ *(.*)$' while IFS= read -r line; do line="${line//$'\r'}" let index+=1 - if [[ "$line" =~ $pattern ]]; then + if [[ "$line" =~ $BATS_TEST_PATTERN ]]; then name="${BASH_REMATCH[1]#[\'\"]}" name="${name%[\'\"]}" body="${BASH_REMATCH[2]}"