diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-19 12:42:10 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-19 12:42:10 -0500 |
| commit | bd6881adbe25272278031b419bedd5811ef3828c (patch) | |
| tree | 3b0b9b9f771d2c589ef90f42dbd07c4713ceebfb | |
| parent | 019db5f9677902ba02d703a8554667d1b6e88f6b (diff) | |
| download | rulesets-bd6881adbe25272278031b419bedd5811ef3828c.tar.gz rulesets-bd6881adbe25272278031b419bedd5811ef3828c.zip | |
refactor(elisp): generalize validate-el.sh test-runner for flat layouts
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
| -rwxr-xr-x[-rw-r--r--] | languages/elisp/claude/hooks/validate-el.sh | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/languages/elisp/claude/hooks/validate-el.sh b/languages/elisp/claude/hooks/validate-el.sh index 5fd4241..956feaa 100644..100755 --- 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[@]}" |
