aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 19:45:26 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 19:45:26 -0500
commite7f15034f1b4dea7fb22ebc0f2f532ee06b3dd57 (patch)
tree4171c4bbf9ffcd9230ba61b0285d328bd7b3972f /tests
parentc5ff668aa2666e70ce423cf382b9871ed069a527 (diff)
downloadpearl-e7f15034f1b4dea7fb22ebc0f2f532ee06b3dd57.tar.gz
pearl-e7f15034f1b4dea7fb22ebc0f2f532ee06b3dd57.zip
build: resolve test-file to the exact name before globbing
make test-file FILE=test-pearl-save grabbed test-pearl-saved.el — the glob *FILE*.el matched both and head -1 picked one arbitrarily. It now prefers an exact FILE or FILE.el match, and errors with the candidate list when a bare substring matches more than one file, instead of silently running the wrong one.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile
index a6b6812..c011359 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -93,11 +93,19 @@ ifndef FILE
@echo " make test-file FILE=test-pearl-mapping.el"
@exit 1
endif
- @TESTFILE=$$(find . -maxdepth 1 -name "*$(FILE)*.el" -type f | head -1 | sed 's|^\./||'); \
+ @TESTFILE=$$( \
+ if [ -f "$(FILE)" ]; then echo "$(FILE)"; \
+ elif [ -f "$(FILE).el" ]; then echo "$(FILE).el"; \
+ else find . -maxdepth 1 -name "*$(FILE)*.el" -type f | sed 's|^\./||'; fi); \
if [ -z "$$TESTFILE" ]; then \
printf "$(RED)Error: No test file matching '$(FILE)' found$(NC)\n"; \
exit 1; \
fi; \
+ if [ "$$(printf '%s\n' "$$TESTFILE" | grep -c .)" -gt 1 ]; then \
+ printf "$(RED)Error: '$(FILE)' matches multiple files; pass the exact name (e.g. $(FILE).el):$(NC)\n"; \
+ printf '%s\n' "$$TESTFILE" | sed 's|^| |'; \
+ exit 1; \
+ fi; \
printf "$(YELLOW)Running tests in $$TESTFILE...$(NC)\n"; \
$(EMACS_BATCH) -l ert -l "$$TESTFILE" \
--eval "$(ERT_FAST_SELECTOR)" 2>&1 | tee $(PROJECT_ROOT)/tests/test-file-output.log; \