From f867f50d1675d5f9a251f7b5a2633d2eac3f0de7 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 25 May 2026 17:51:17 -0500 Subject: fix(org): guard external-tool assumptions in export and publishing commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/test-hugo-config-open-blog-dir-external.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/test-hugo-config-open-blog-dir-external.el') diff --git a/tests/test-hugo-config-open-blog-dir-external.el b/tests/test-hugo-config-open-blog-dir-external.el index ae4a25ba..0bf68982 100644 --- a/tests/test-hugo-config-open-blog-dir-external.el +++ b/tests/test-hugo-config-open-blog-dir-external.el @@ -44,6 +44,7 @@ filesystem checks." (cl-letf (((symbol-function 'env-macos-p) (lambda () ,macos-p)) ((symbol-function 'env-windows-p) (lambda () ,windows-p)) ((symbol-function 'file-directory-p) (lambda (_d) t)) + ((symbol-function 'executable-find) (lambda (cmd) cmd)) ((symbol-function 'start-process) (lambda (_name _buf cmd &rest _args) (setq test-hugo--captured-process-cmd cmd)))) @@ -85,6 +86,7 @@ filesystem checks." ((symbol-function 'file-directory-p) (lambda (_d) nil)) ((symbol-function 'make-directory) (lambda (_dir &rest _args) (setq mkdir-called t))) + ((symbol-function 'executable-find) (lambda (cmd) cmd)) ((symbol-function 'start-process) #'ignore)) (cj/hugo-open-blog-dir-external) (should mkdir-called)))) @@ -97,9 +99,22 @@ filesystem checks." ((symbol-function 'file-directory-p) (lambda (_d) t)) ((symbol-function 'make-directory) (lambda (_dir &rest _args) (setq mkdir-called t))) + ((symbol-function 'executable-find) (lambda (cmd) cmd)) ((symbol-function 'start-process) #'ignore)) (cj/hugo-open-blog-dir-external) (should-not mkdir-called)))) +;;; Error Cases + +(ert-deftest test-hugo-config-open-blog-dir-external-error-opener-missing () + "Error: missing opener executable signals user-error before start-process." + (cl-letf (((symbol-function 'env-macos-p) (lambda () nil)) + ((symbol-function 'env-windows-p) (lambda () nil)) + ((symbol-function 'file-directory-p) (lambda (_d) t)) + ((symbol-function 'executable-find) (lambda (_) nil)) + ((symbol-function 'start-process) + (lambda (&rest _) (error "start-process should not run")))) + (should-error (cj/hugo-open-blog-dir-external) :type 'user-error))) + (provide 'test-hugo-config-open-blog-dir-external) ;;; test-hugo-config-open-blog-dir-external.el ends here -- cgit v1.2.3