aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-07 10:27:17 -0500
committerCraig Jennings <c@cjennings.net>2026-06-07 10:27:17 -0500
commitd733bb29763d6e936b460dcf136a491c156eb888 (patch)
treef7a25f46b62b25cd0ed0c4e33b13db44ce265af0
parentbecf642a49b03d81176df530fe2a0db1e0694597 (diff)
downloadrulesets-d733bb29763d6e936b460dcf136a491c156eb888.tar.gz
rulesets-d733bb29763d6e936b460dcf136a491c156eb888.zip
fix(elisp-hook): show a compact test summary in the terminal on failure
validate-el.sh dumped the full ERT batch output to the terminal on a red test, every backtrace frame, flooding the pane. It now prints a short summary there: the run tally plus the failing test names and their file:line. Claude still gets the full backtrace through additionalContext. fail_json takes an optional fourth argument for the terminal echo. Paren and byte-compile failures stay short, so they still print in full.
-rwxr-xr-xlanguages/elisp/claude/hooks/validate-el.sh16
1 files changed, 13 insertions, 3 deletions
diff --git a/languages/elisp/claude/hooks/validate-el.sh b/languages/elisp/claude/hooks/validate-el.sh
index 782f04c..d6999ac 100755
--- a/languages/elisp/claude/hooks/validate-el.sh
+++ b/languages/elisp/claude/hooks/validate-el.sh
@@ -15,7 +15,11 @@ set -u
# Emit a JSON failure payload and exit 2. Arguments:
# $1 — short failure type (e.g. "PAREN CHECK FAILED")
# $2 — file path
-# $3 — emacs output (error body)
+# $3 — emacs output (error body), always sent to Claude in additionalContext
+# $4 — optional compact terminal echo; when set, the terminal shows this
+# instead of the full $3 (Claude still gets the full $3). Used by the
+# test runner so a failing suite prints a short summary to the pane
+# rather than dumping every ERT backtrace.
fail_json() {
local ctx
ctx="$(printf '%s: %s\n\n%s\n\nFix before proceeding.' "$1" "$2" "$3" \
@@ -23,7 +27,7 @@ fail_json() {
cat <<EOF
{"hookSpecificOutput": {"hookEventName": "PostToolUse", "additionalContext": $ctx}}
EOF
- printf '%s: %s\n%s\n' "$1" "$2" "$3" >&2
+ printf '%s: %s\n%s\n' "$1" "$2" "${4:-$3}" >&2
exit 2
}
@@ -97,7 +101,13 @@ if [ "$count" -ge 1 ] && [ "$count" -le "$MAX_AUTO_TEST_FILES" ]; then
--eval '(package-initialize)' \
-l ert "${load_args[@]}" \
--eval "(ert-run-tests-batch-and-exit '(not (tag :slow)))" 2>&1)"; then
- fail_json "TESTS FAILED ($count test file(s))" "$f" "$output"
+ # Terminal gets a compact summary (the run tally + the failing test names);
+ # Claude still gets the full backtrace via additionalContext. Keeps the
+ # pane from drowning in ERT stack frames on every red test.
+ summary="$(printf '%s\n' "$output" \
+ | grep -E '^Ran [0-9]+ tests|unexpected results:|^[[:space:]]+FAILED' || true)"
+ [ -n "$summary" ] && summary="${summary}"$'\n'"(full backtrace in Claude's context)"
+ fail_json "TESTS FAILED ($count test file(s))" "$f" "$output" "$summary"
fi
fi