diff options
Diffstat (limited to 'check.sh')
| -rwxr-xr-x | check.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..d243171 --- /dev/null +++ b/check.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Validate emacs.el by loading it in a batch Emacs. +# Run this before committing changes to your config. +# +# PASS = file loads with exit 0 and no errors. +# Warnings are shown but do not fail the check. +set -uo pipefail + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +INIT="$REPO_DIR/emacs.el" +OUTPUT=$(mktemp) +trap 'rm -f "$OUTPUT"' EXIT + +timeout 180 emacs --batch -l "$INIT" >"$OUTPUT" 2>&1 +STATUS=$? + +echo "--- emacs --batch -l emacs.el (exit $STATUS) ---" +cat "$OUTPUT" +echo "--- end output ---" + +ERRORS=$(grep -cE "^(Error|error|Cannot open|File mode specification error)" "$OUTPUT") +WARNINGS=$(grep -c "^Warning" "$OUTPUT" || true) + +if [ "$STATUS" -eq 0 ] && [ "$ERRORS" -eq 0 ]; then + echo "PASS: config loads cleanly ($WARNINGS warning(s))" + exit 0 +else + echo "FAIL: config has errors (see output above)" + exit 1 +fi |
