Skip to content

Commit 25f1534

Browse files
committed
add shell script syntax check to tests
1 parent d493461 commit 25f1534

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/run_tests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,24 @@ else
458458
echo " SKIP: RPC script not found at $RPC_SCRIPT"
459459
fi
460460

461+
###############################################################################
462+
# SHELL SCRIPT SYNTAX #
463+
###############################################################################
464+
465+
printf "\n--- Shell script syntax ---\n"
466+
for shellscript in \
467+
root/etc/uci-defaults/*; do
468+
[ -f "$shellscript" ] || continue
469+
head -1 "$shellscript" | grep -q '^#!/bin/sh' || continue
470+
name="${shellscript#root/}"
471+
n_tests=$((n_tests + 1))
472+
if sh -n "$shellscript" 2>/dev/null; then
473+
pass "sh -n $name"
474+
else
475+
fail "sh -n $name" "$(sh -n "$shellscript" 2>&1)"
476+
fi
477+
done
478+
461479
###############################################################################
462480
# SUMMARY #
463481
###############################################################################

0 commit comments

Comments
 (0)