aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-22 16:09:49 -0500
committerCraig Jennings <c@cjennings.net>2026-05-22 16:09:49 -0500
commit4fbe435f515a26ea11732c982900a1f011dff589 (patch)
tree9e75be07cbc64220d15df48a8b4f4fe2d40753cb
parent98477bda43a9f0549f7b1998d9bff5bb87af9387 (diff)
downloaddotemacs-4fbe435f515a26ea11732c982900a1f011dff589.tar.gz
dotemacs-4fbe435f515a26ea11732c982900a1f011dff589.zip
fix(test): make test-name resilient to load-time cwd changes
make test-name loads every test file into one Emacs, then selects by name. test-system-defaults-functions.el requires system-defaults at load, which runs (setq default-directory user-home-dir), an intentional config choice. That leaked the cwd into the shared session, so every relative -l tests/X.el load after it resolved against the wrong directory and aborted the whole run with Error 255. I made two changes. test-name now passes absolute paths to -l so loads survive any cwd change, and the test contains the leak by let-binding default-directory around the require. The production setq stays as is.
-rw-r--r--Makefile2
-rw-r--r--tests/test-system-defaults-functions.el7
2 files changed, 7 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 4e19149d..26cb7619 100644
--- a/Makefile
+++ b/Makefile
@@ -204,7 +204,7 @@ endif
@echo "Running tests matching pattern: $(TEST)..."
@$(EMACS_TEST) \
-l ert \
- $(foreach test,$(ALL_TESTS),-l $(test)) \
+ $(foreach test,$(ALL_TESTS),-l $(abspath $(test))) \
--eval '(ert-run-tests-batch-and-exit "$(TEST)")'
@echo "✓ Tests matching '$(TEST)' complete"
diff --git a/tests/test-system-defaults-functions.el b/tests/test-system-defaults-functions.el
index 580e7a7c..154e3678 100644
--- a/tests/test-system-defaults-functions.el
+++ b/tests/test-system-defaults-functions.el
@@ -47,7 +47,12 @@
;; bodies. Stubs deliberately scope only to the require so the
;; real primitives remain available for unrelated tests in the
;; same Emacs.
-(let ((use-package-always-ensure nil))
+;; Contain system-defaults' load-time `(setq default-directory user-home-dir)'
+;; so it doesn't leak into a shared batch session. `make test-name' loads
+;; every test file into one Emacs; a leaked cwd there breaks the relative
+;; loads of every file that follows.
+(let ((default-directory default-directory)
+ (use-package-always-ensure nil))
(cl-letf (((symbol-function 'server-running-p) (lambda (&rest _) t))
((symbol-function 'server-start) #'ignore)
((symbol-function 'set-locale-environment) #'ignore)