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

55 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
pass=0
fail=0
checker=""
if command -v yamllint &>/dev/null; then
checker=yamllint
elif python3 -c "import yaml" 2>/dev/null; then
checker=python
fi
test_yaml() {
local file=$1
case "$checker" in
yamllint)
if yamllint -d "{extends: relaxed, rules: {line-length: disable}}" "$file"; then
echo " PASS $file"
pass=$((pass+1))
else
echo " FAIL $file"
fail=$((fail+1))
fi
;;
python)
if python3 -c "
import yaml, sys
with open('$file') as f:
yaml.safe_load(f)
" 2>/dev/null; then
echo " PASS $file"
pass=$((pass+1))
else
echo " FAIL $file"
fail=$((fail+1))
fi
;;
*)
echo " SKIP $file (no yamllint or PyYAML)"
pass=$((pass+1))
;;
esac
}
echo "=== YAML Validation ==="
for f in "$@"; do
[ -f "$f" ] && test_yaml "$f"
done
echo "---"
echo "Passed: $pass Failed: $fail"
[ "$fail" -eq 0 ]