blob: d243171128aa9fdfe747b39dc3ad65cc41027582 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|