aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-03 19:59:42 -0500
committerCraig Jennings <c@cjennings.net>2026-05-03 19:59:42 -0500
commitdeff663d480afb23e47f0d0fd834d2c0959d0b00 (patch)
tree0d6ca6f4c429e3623ae6b69d19ff1716852856f2 /Makefile
parent3e9499f62c4fb621ec234a0cf5cee51eb2cf32c0 (diff)
downloaddotemacs-deff663d480afb23e47f0d0fd834d2c0959d0b00.tar.gz
dotemacs-deff663d480afb23e47f0d0fd834d2c0959d0b00.zip
fix: make test scratch paths sandbox-friendly
`tests/testutil-general.el` hard-coded `~/.temp-emacs-tests/` as the test root. That worked locally but blew up under sandboxed `make` runs and CI environments that can't write outside the repo or `/tmp`. A clean sandbox `make test` run reported 32 failing test files purely from the home-directory write attempt, even though the same suite passed when run with normal write permission. I rewrote `cj/test-base-dir` to honor `CJ_EMACS_TEST_DIR` if set, otherwise create a unique directory under `temporary-file-directory` via `make-temp-file`. So sandbox and CI paths just work, and a stable local debug root is still one env-var away. I also tightened the path-containment checks. The old `(string-prefix-p base fullpath)` was a textual hack. Relative paths and weird trailing slashes could fool it. I extracted `cj/test--assert-inside-base` using `file-in-directory-p`, which is the proper API. While I was there, I added `cj/test--safe-base-dir-p` so `cj/delete-test-base-dir` refuses to recursively wipe `/`, `~/`, `temporary-file-directory`, `user-emacs-directory`, `default-directory`, or any path of length under six characters. That guards against an env-var typo or a misaligned `let` binding accidentally deleting something important. I updated the Makefile's `clean-tests` target to nuke the new `$TMPDIR/cj-emacs-tests-*` pattern plus an explicit `CJ_EMACS_TEST_DIR` (if set) and the legacy `~/.temp-emacs-tests` directory. I added `tests/test-testutil-general.el` with five tests: default base lives under `temporary-file-directory`, env override resolves correctly, parent-escape paths are rejected, broad roots are refused for deletion, and a specific selected root is cleaned cleanly.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile3
1 files changed, 2 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index a7183d85..2006f5f4 100644
--- a/Makefile
+++ b/Makefile
@@ -379,7 +379,8 @@ clean-compiled:
clean-tests:
@echo "Removing test artifacts..."
- @rm -rf $(HOME)/.temp-emacs-tests
+ @test_dir="$${CJ_EMACS_TEST_DIR:-$${TMPDIR:-/tmp}/cj-emacs-tests}"; \
+ rm -rf "$$test_dir" "$${TMPDIR:-/tmp}"/cj-emacs-tests-* "$(HOME)/.temp-emacs-tests"
@echo "✓ Test artifacts removed"
reset: