From bd6881adbe25272278031b419bedd5811ef3828c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 19 Apr 2026 12:42:10 -0500 Subject: refactor(elisp): generalize validate-el.sh test-runner for flat layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 2 test lookup now triggers for any .el file outside tests/, not just modules/*.el. Stem-based test matching works the same way; this just broadens the case pattern. Before: only modules/foo.el → tests/test-foo*.el triggered Phase 2. After: foo.el, lib/foo.el, modules/foo.el all do. init.el and early-init.el are still Phase-1-only (byte-compile would load the full package graph). Verified on: - emacs.d (modules/-based): modules/browser-config.el still runs its matching test, exit 0 - flat layout (scratch /tmp): source.el at project root successfully finds and runs tests/test-source.el --- languages/elisp/claude/hooks/validate-el.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) mode change 100644 => 100755 languages/elisp/claude/hooks/validate-el.sh (limited to 'languages/elisp/claude/hooks') diff --git a/languages/elisp/claude/hooks/validate-el.sh b/languages/elisp/claude/hooks/validate-el.sh old mode 100644 new mode 100755 index 5fd4241..956feaa --- a/languages/elisp/claude/hooks/validate-el.sh +++ b/languages/elisp/claude/hooks/validate-el.sh @@ -44,12 +44,13 @@ case "$f" in esac # --- Phase 2: test runner --- -# Determine which tests (if any) apply to this edit. +# Determine which tests (if any) apply to this edit. Works for projects with +# source at root, in modules/, or elsewhere — stem-based test lookup is the +# common pattern. tests=() case "$f" in - "$PROJECT_ROOT/modules/"*.el) - stem="$(basename "${f%.el}")" - mapfile -t tests < <(find "$PROJECT_ROOT/tests" -maxdepth 1 -name "test-${stem}*.el" 2>/dev/null | sort) + */init.el|*/early-init.el) + : # Phase 1 handled it; skip test runner ;; "$PROJECT_ROOT/tests/testutil-"*.el) stem="$(basename "${f%.el}")" @@ -59,6 +60,11 @@ case "$f" in "$PROJECT_ROOT/tests/test-"*.el) tests=("$f") ;; + *.el) + # Any other .el under the project — find matching tests by stem + stem="$(basename "${f%.el}")" + mapfile -t tests < <(find "$PROJECT_ROOT/tests" -maxdepth 1 -name "test-${stem}*.el" 2>/dev/null | sort) + ;; esac count="${#tests[@]}" -- cgit v1.2.3