aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-29 04:47:44 -0400
committerCraig Jennings <c@cjennings.net>2026-06-29 04:47:44 -0400
commit3ca9a9f17daa3d6258aa9f32a1a56a9f9e19642c (patch)
treeef653ae4f4366afc9fe99c147035a9bd8bb6d416 /tests
parent37d53dacf0636ae299b092b54dde78c0658a51c1 (diff)
downloaddotemacs-3ca9a9f17daa3d6258aa9f32a1a56a9f9e19642c.tar.gz
dotemacs-3ca9a9f17daa3d6258aa9f32a1a56a9f9e19642c.zip
test: fix restart-emacs no-service mock to survive native-comp
test-system-cmd-restart-emacs-no-service-aborts mocked cj/system-cmd--emacs-service-available-p directly, but cj/system-cmd-restart-emacs reaches that helper through a native-comp intra-file direct call that bypasses the symbol-function redefinition. The mock silently no-opped, the real check ran, and on any machine that has emacs.service it returned non-nil, so restart proceeded and the should-error saw no error. I mock executable-find to nil instead, driving the real helper to nil at a boundary its subr trampoline honors, matching the passing sibling tests. The test now passes whether or not emacs.service is installed.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-system-commands-resolve-and-run.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/test-system-commands-resolve-and-run.el b/tests/test-system-commands-resolve-and-run.el
index af2288fd9..9d92c5d68 100644
--- a/tests/test-system-commands-resolve-and-run.el
+++ b/tests/test-system-commands-resolve-and-run.el
@@ -172,9 +172,15 @@ does not run the command."
(ert-deftest test-system-cmd-restart-emacs-no-service-aborts ()
"Error: when no emacs.service exists, restart aborts without running anything."
(let ((ran nil))
+ ;; Drive the real service check to nil at its boundary (no systemctl on
+ ;; PATH) rather than mocking cj/system-cmd--emacs-service-available-p
+ ;; itself: cj/system-cmd-restart-emacs reaches that helper through a
+ ;; native-comp intra-file direct call that bypasses a symbol-function
+ ;; redefinition, so the helper-level mock silently no-ops and the real
+ ;; check passes on a machine that has emacs.service. executable-find is a
+ ;; subr the helper calls, and its trampoline honors the cl-letf swap.
(cl-letf (((symbol-function 'daemonp) (lambda () t))
- ((symbol-function 'cj/system-cmd--emacs-service-available-p)
- (lambda () nil))
+ ((symbol-function 'executable-find) (lambda (&rest _) nil))
((symbol-function 'read-char-choice) (lambda (&rest _) ?y))
((symbol-function 'call-process-shell-command)
(lambda (&rest _) (setq ran t))))