From 7e03862f6315af4b960cbbbe670764cbd49b09d1 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 9 Jul 2026 16:12:44 -0500 Subject: fix(tests): report failure from test-file and validate Both targets read $? after a pipeline, so they got the exit status of the last command in it rather than of Emacs. test-file piped Emacs through tee, so it printed "All tests passed" over a wall of FAILED lines and exited 0. It now redirects to the log, saves the status, and cats the log back. validate piped Emacs through grep, and grep matched the failure line it was looking for, so a file with unbalanced parens printed its error in green and counted as validated. It now captures the output and the status separately. Verified against a deliberately broken file: before the fix, "All 78 files validated successfully" and exit 0. make test and make test-all were never affected. They shell out to test-unit and test-integration without a pipeline. --- tests/Makefile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 8fd2e0c..6425304 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -100,8 +100,10 @@ endif 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; \ - if [ $$? -eq 0 ]; then \ + --eval "$(ERT_FAST_SELECTOR)" > $(PROJECT_ROOT)/tests/test-file-output.log 2>&1; \ + status=$$?; \ + cat $(PROJECT_ROOT)/tests/test-file-output.log; \ + if [ $$status -eq 0 ]; then \ printf "$(GREEN)✓ All tests in $$TESTFILE passed!$(NC)\n"; \ else \ printf "$(RED)✗ Some tests failed.$(NC)\n"; \ @@ -201,7 +203,7 @@ validate: for file in ../chime.el test-*.el testutil-*.el; do \ if [ -f "$$file" ] && [ ! -d "$$file" ]; then \ total=$$((total + 1)); \ - output=$$(emacs --batch -Q --eval "(progn \ + raw=$$(emacs --batch -Q --eval "(progn \ (setq byte-compile-error-on-warn nil) \ (find-file \"$$file\") \ (condition-case err \ @@ -210,8 +212,10 @@ validate: (message \"✓ $$file - parentheses balanced\")) \ (error \ (message \"✗ $$file: %s\" (error-message-string err)) \ - (kill-emacs 1))))" 2>&1 | grep -E '(✓|✗)'); \ - if [ $$? -eq 0 ]; then \ + (kill-emacs 1))))" 2>&1); \ + status=$$?; \ + output=$$(printf '%s\n' "$$raw" | grep -E '(✓|✗)'); \ + if [ $$status -eq 0 ]; then \ printf "$(GREEN)$$output$(NC)\n"; \ else \ printf "$(RED)$$output$(NC)\n"; \ -- cgit v1.2.3