aboutsummaryrefslogtreecommitdiff
path: root/tests/test-org-reveal-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
commitd665582d6fc19c15a772c6ec24ff822e7e3c37f9 (patch)
tree40c44ed42cd4e4805de626221eae88a05ea484d1 /tests/test-org-reveal-config-commands.el
parentc414a6346f970f0ac49f92222471efeaf7e922d0 (diff)
downloaddotemacs-d665582d6fc19c15a772c6ec24ff822e7e3c37f9.tar.gz
dotemacs-d665582d6fc19c15a772c6ec24ff822e7e3c37f9.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-org-reveal-config-commands.el')
-rw-r--r--tests/test-org-reveal-config-commands.el18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/test-org-reveal-config-commands.el b/tests/test-org-reveal-config-commands.el
index c2829f0c..fdec9bea 100644
--- a/tests/test-org-reveal-config-commands.el
+++ b/tests/test-org-reveal-config-commands.el
@@ -80,7 +80,8 @@
(msg nil))
(with-temp-buffer
(delay-mode-hooks (org-mode))
- (cl-letf (((symbol-function 'org-reveal-export-to-html)
+ (cl-letf (((symbol-function 'file-directory-p) (lambda (_) t))
+ ((symbol-function 'org-reveal-export-to-html)
(lambda (&rest _) "/tmp/talk.html"))
((symbol-function 'browse-url-of-file)
(lambda (f) (setq opened f)))
@@ -91,6 +92,18 @@
(should (equal opened "/tmp/talk.html"))
(should (string-match-p "Opened presentation" msg))))
+(ert-deftest test-reveal-export-errors-when-reveal-root-missing ()
+ "Error: when the local reveal.js dir is absent, export signals user-error."
+ (with-temp-buffer
+ (delay-mode-hooks (org-mode))
+ (cl-letf (((symbol-function 'file-directory-p) (lambda (_) nil))
+ ((symbol-function 'org-reveal-export-to-html)
+ (lambda (&rest _) (error "Exporter should not be reached"))))
+ (let ((err (should-error (cj/reveal-export) :type 'user-error)))
+ (should (string-match-p "reveal\\.js" (error-message-string err)))
+ (should (string-match-p "setup-reveal\\.sh"
+ (error-message-string err)))))))
+
;;; cj/reveal-preview-start
(ert-deftest test-reveal-preview-start-installs-hook-and-exports ()
@@ -99,7 +112,8 @@
(opened nil))
(with-temp-buffer
(delay-mode-hooks (org-mode))
- (cl-letf (((symbol-function 'org-reveal-export-to-html)
+ (cl-letf (((symbol-function 'file-directory-p) (lambda (_) t))
+ ((symbol-function 'org-reveal-export-to-html)
(lambda (&rest _) (setq exported t) "/tmp/preview.html"))
((symbol-function 'browse-url-of-file)
(lambda (f) (setq opened f)))