Skip to content

Commit b22811a

Browse files
committed
add shell script syntax check to tests
1 parent e563778 commit b22811a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/run_tests.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,26 @@ load_package_config
611611
assert_eq "load_package_config: canary disabled → canaryDomains empty" "" "$canaryDomains"
612612
assert_eq "load_package_config: force_dns=0 → unset" "" "$force_dns"
613613

614+
###############################################################################
615+
# SHELL SCRIPT SYNTAX #
616+
###############################################################################
617+
618+
printf "\n--- Shell script syntax ---\n"
619+
for shellscript in \
620+
files/etc/init.d/* \
621+
files/etc/uci-defaults/*; do
622+
[ -f "$shellscript" ] || continue
623+
head -1 "$shellscript" | grep -q '^#!/bin/sh' || continue
624+
name="${shellscript#files/}"
625+
n_tests=$((n_tests + 1))
626+
if sh -n "$shellscript" 2>/dev/null; then
627+
pass "sh -n $name"
628+
else
629+
fail "sh -n $name" "syntax ok" "syntax error"
630+
sh -n "$shellscript"
631+
fi
632+
done
633+
614634
###############################################################################
615635
# SUMMARY #
616636
###############################################################################

0 commit comments

Comments
 (0)