diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-07 10:27:30 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-07 10:27:30 -0500 |
| commit | 9507cd4b63294a151a94ef91ef82ee24a108ee58 (patch) | |
| tree | 54d4889a12fc1c700876d3249f76724226b34c87 | |
| parent | 8c2204a24169d5a9817fc2212a6deed0270c46f8 (diff) | |
| download | dotemacs-9507cd4b63294a151a94ef91ef82ee24a108ee58.tar.gz dotemacs-9507cd4b63294a151a94ef91ef82ee24a108ee58.zip | |
chore(hooks): sync validate-el.sh compact test output from the bundle
The bundle hook now prints a short test summary to the terminal on a red test (the run tally and the failing test names) and keeps the full ERT backtrace in the agent's context. Synced the project copy to match.
| -rwxr-xr-x | .claude/hooks/validate-el.sh | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/.claude/hooks/validate-el.sh b/.claude/hooks/validate-el.sh index 782f04ca..d6999ac0 100755 --- a/.claude/hooks/validate-el.sh +++ b/.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 |
