From e7f15034f1b4dea7fb22ebc0f2f532ee06b3dd57 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 25 May 2026 19:45:26 -0500 Subject: build: resolve test-file to the exact name before globbing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/Makefile') 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; \ -- cgit v1.2.3