aboutsummaryrefslogtreecommitdiff
path: root/tests/test-hugo-config-commands.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 17:51:17 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 17:51:17 -0500
commitf867f50d1675d5f9a251f7b5a2633d2eac3f0de7 (patch)
treef7ae2a1b5d76d3434dc7ad745306bd0c2b04896a /tests/test-hugo-config-commands.el
parentda926d8d0af456512313b40d7625bb21ced63a8e (diff)
downloaddotemacs-f867f50d1675d5f9a251f7b5a2633d2eac3f0de7.tar.gz
dotemacs-f867f50d1675d5f9a251f7b5a2633d2eac3f0de7.zip
fix(org): guard external-tool assumptions in export and publishing commands
Four export/publishing commands shelled out to external tools without checking they exist, so a missing tool surfaced as an opaque process error — or, for reveal.js, a silently broken presentation. I added a command-time guard to each that names the tool and what's needed: - zathura, in the pandoc PDF export-and-open command - the hugo binary and the platform file-manager opener, in hugo-config - the local reveal.js checkout (run scripts/setup-reveal.sh), shared by the reveal export and preview commands - pandoc, in the web-clip protocol handler The checks run only when the command runs, so startup stays quiet. Each guard has a test asserting the user-error fires when the tool is absent, and the existing happy-path tests now stub the lookups so they exercise the real path rather than tripping the new guard.
Diffstat (limited to 'tests/test-hugo-config-commands.el')
-rw-r--r--tests/test-hugo-config-commands.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test-hugo-config-commands.el b/tests/test-hugo-config-commands.el
index a387d57d..01df5fc1 100644
--- a/tests/test-hugo-config-commands.el
+++ b/tests/test-hugo-config-commands.el
@@ -210,6 +210,7 @@ stubbed before the org-mode-derived guard runs."
(let ((cj/hugo--preview-process nil)
(start-args nil))
(cl-letf (((symbol-function 'process-live-p) (lambda (_) nil))
+ ((symbol-function 'executable-find) (lambda (_) "/usr/bin/hugo"))
((symbol-function 'start-process)
(lambda (&rest args)
(setq start-args args)
@@ -221,6 +222,16 @@ stubbed before the org-mode-derived guard runs."
(should (eq cj/hugo--preview-process 'fake-proc))
(should (member "server" start-args))))
+(ert-deftest test-hugo-preview-errors-when-hugo-missing ()
+ "Error: a missing hugo binary signals user-error before start-process."
+ (let ((cj/hugo--preview-process nil))
+ (cl-letf (((symbol-function 'process-live-p) (lambda (_) nil))
+ ((symbol-function 'executable-find) (lambda (_) nil))
+ ((symbol-function 'start-process)
+ (lambda (&rest _) (error "start-process should not run")))
+ ((symbol-function 'message) #'ignore))
+ (should-error (cj/hugo-preview) :type 'user-error))))
+
;;; cj/hugo-publish
(ert-deftest test-hugo-publish-opens-magit-on-website-dir ()