mirror of
https://github.com/sstephenson/bats.git
synced 2026-02-25 17:28:11 +01:00
Support single-line test definitions
This commit is contained in:
@@ -31,16 +31,17 @@ encode_name() {
|
||||
|
||||
tests=()
|
||||
index=0
|
||||
pattern='^ *@test *([^ ].*) *\{ *$'
|
||||
pattern='^ *@test *([^ ].*) *\{ *(.*)$'
|
||||
|
||||
while IFS= read -r line; do
|
||||
let index+=1
|
||||
if [[ "$line" =~ $pattern ]]; then
|
||||
quoted_name="${BASH_REMATCH[1]}"
|
||||
body="${BASH_REMATCH[2]}"
|
||||
name="$(eval echo "$quoted_name")"
|
||||
encoded_name="$(encode_name "$name")"
|
||||
tests["${#tests[@]}"]="$encoded_name"
|
||||
echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}"
|
||||
echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}"
|
||||
else
|
||||
printf "%s\n" "$line"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user