support multiline bats test declarations in syntax checker

Co-authored-by: m-1-k-3 <[email protected]>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-14 15:17:16 +00:00
committed by GitHub
co-authored by m-1-k-3
parent 2d521f9de5
commit 169293c81e
+17 -2
View File
@@ -51,10 +51,25 @@ check_bats_syntax() {
lBATS_TEMP_FILE="$(mktemp)"
trap 'rm -f "${lBATS_TEMP_FILE}"' RETURN
awk '
BEGIN { lTEST_CNT=0 }
/^[[:space:]]*@test[[:space:]].*\{$/ {
BEGIN { lTEST_CNT=0; lTEST_DECL=0 }
lTEST_DECL == 1 {
if ($0 ~ /^[[:space:]]*{[[:space:]]*$/) {
lTEST_DECL=0
next
}
lTEST_DECL=0
}
/^[[:space:]]*@test[[:space:]].*\{[[:space:]]*$/ {
lTEST_CNT+=1
sub(/^[[:space:]]*@test[[:space:]].*\{$/, "function bats_test_placeholder_" lTEST_CNT "() {")
print
next
}
/^[[:space:]]*@test[[:space:]]+/ {
lTEST_CNT+=1
print "function bats_test_placeholder_" lTEST_CNT "() {"
lTEST_DECL=1
next
}
{ print }
' "${lBATS_FILE}" >"${lBATS_TEMP_FILE}"