diff options
| -rw-r--r-- | modules/calendar-sync.el | 4 | ||||
| -rw-r--r-- | tests/test-calendar-sync-async-worker.el | 23 |
2 files changed, 26 insertions, 1 deletions
diff --git a/modules/calendar-sync.el b/modules/calendar-sync.el index 74b2e5c6..62d1b5f1 100644 --- a/modules/calendar-sync.el +++ b/modules/calendar-sync.el @@ -1282,7 +1282,8 @@ processes, not direct interactive use." (defun calendar-sync--worker-command (ics-file output-file) "Build the batch Emacs command that converts ICS-FILE to OUTPUT-FILE." - (let ((private-config-file + (let ((module-dir (file-name-directory calendar-sync--module-file)) + (private-config-file (make-temp-name (expand-file-name "calendar-sync-worker-config-" temporary-file-directory))) (state-file @@ -1294,6 +1295,7 @@ processes, not direct interactive use." "--no-site-lisp" "--eval" (format "(setq load-prefer-newer t calendar-sync-auto-start nil calendar-sync-private-config-file %S calendar-sync--state-file %S)" private-config-file state-file) + "-L" module-dir "-l" calendar-sync--module-file "--eval" (format "(calendar-sync--batch-convert-file %S %S %S %S '%S)" ics-file 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")) |
