Files
wordpress/tests/test_shell.sh
T
2026-06-02 23:36:02 +01:00

38 lines
776 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
pass=0
fail=0
EXTRA_SHELLCHECK_OPTS="${SHELLCHECK_OPTS:-}"
shellcheck_tmpl() {
local tmpl=$1
# Strip Go template tags ({{ ... }} and {{- ... -}}) into whitespace
# so shellcheck can parse the remaining bash.
local cleaned
cleaned=$(sed 's/{{[-]*[^}]*[-]*}}/true/g' "$tmpl")
local tmpfile
tmpfile=$(mktemp)
printf '%s\n' "$cleaned" > "$tmpfile"
if shellcheck $EXTRA_SHELLCHECK_OPTS "$tmpfile"; then
echo " PASS $tmpl"
pass=$((pass + 1))
else
echo " FAIL $tmpl"
fail=$((fail + 1))
fi
rm -f "$tmpfile"
}
echo "=== ShellCheck ==="
for f in "$@"; do
[ -f "$f" ] && shellcheck_tmpl "$f"
done
echo "---"
echo "Passed: $pass Failed: $fail"
[ "$fail" -eq 0 ]