From e958410cbc14d2bfa0f97890aafe38031e082aa7 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 11 May 2026 17:17:53 -0500 Subject: fix(calendar-sync): give the no-init .ics worker its module load-path The async .ics-to-Org worker runs `emacs --batch --no-site-file --no-site-lisp' and loads `calendar-sync.el' by absolute path, but that doesn't make its sibling `(require 'cj-org-text-lib)' resolvable, so the conversion died with "Cannot open load file: cj-org-text-lib". `calendar-sync--worker-command' now inserts `-L ' before `-l calendar-sync.el', which keeps the worker isolated from `init.el' while letting it load its local module deps. Updated the worker-command test and added a regression test that runs the real no-init worker shape. --- tests/test-calendar-sync-async-worker.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/test-calendar-sync-async-worker.el b/tests/test-calendar-sync-async-worker.el index d5982d32..6701df85 100644 --- a/tests/test-calendar-sync-async-worker.el +++ b/tests/test-calendar-sync-async-worker.el @@ -21,6 +21,8 @@ (should (member "--batch" command)) (should (member "--no-site-file" command)) (should (member "--no-site-lisp" command)) + (should (member "-L" command)) + (should (member "/tmp/" command)) (should (member "-l" command)) (should (member "/tmp/calendar-sync.el" command)) (should (cl-some (lambda (arg) @@ -35,6 +37,27 @@ (string-match-p "'(\"me@example\\.test\")" arg))) command)))) +(ert-deftest test-calendar-sync--worker-command-loads-sibling-modules-without-init () + "The worker command should load calendar-sync and sibling modules without init." + (let* ((calendar-sync--module-file + (expand-file-name "modules/calendar-sync.el" user-emacs-directory)) + (command (append + (calendar-sync--worker-command "/tmp/input.ics" "/tmp/output.org") + (list "--eval" "(princ \"loaded\")")))) + ;; Replace the conversion eval with a harmless smoke expression so this + ;; test exercises load-path setup without requiring temp ICS input. + (setq command + (cl-loop for arg in command + collect (if (and (stringp arg) + (string-match-p "calendar-sync--batch-convert-file" arg)) + "(princ \"\")" + arg))) + (with-temp-buffer + (let ((exit-code (apply #'call-process + (car command) nil t nil (cdr command)))) + (should (= 0 exit-code)) + (should (string-match-p "loaded" (buffer-string))))))) + (ert-deftest test-calendar-sync--batch-convert-file-writes-org-output () "The worker entry point should convert an ICS file and write Org output." (let* ((input-file (make-temp-file "calendar-sync-worker-" nil ".ics")) -- cgit v1.2.3