aboutsummaryrefslogtreecommitdiff
path: root/tests/test-org-agenda-config-add-files.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 07:21:44 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 07:21:44 -0500
commit12fb0108ba217f06fb9d40da8431d49540650402 (patch)
tree4d2c6630b3a6bc8f13de45697bc88ba89a257389 /tests/test-org-agenda-config-add-files.el
parentbc9652752c231e8634a90c875ed6d206ff172458 (diff)
downloaddotemacs-12fb0108ba217f06fb9d40da8431d49540650402.tar.gz
dotemacs-12fb0108ba217f06fb9d40da8431d49540650402.zip
fix(org): surface directory-scan failures instead of crashing or hiding them
The refile target scan caught permission-denied and silently dropped the directory, and would crash outright on a missing root (only permission-denied was caught, so a missing code-dir/projects-dir raised file-missing and aborted the whole build). The agenda build had the same crash: cj/add-files-to-org-agenda-files-list called directory-files on projects-dir with no existence check. Extracted cj/--org-refile-scan-dir, which warns (display-warning) and returns nil for a missing, unreadable, or permission-denied root so the rest of the scan continues. Guarded the agenda scan the same way. Both now log a concise warning naming the skipped directory rather than failing silently or fatally. Also fixed a latent bug surfaced here: org-refile-targets was never declared special, so under make compile cj/org-refile-in-file let-bound it lexically and the scoped targets never reached org-refile. Added (defvar org-refile-targets) so the binding stays dynamic when byte-compiled. Tests cover the helper (missing/permission-denied/normal) and the agenda missing-dir guard.
Diffstat (limited to 'tests/test-org-agenda-config-add-files.el')
-rw-r--r--tests/test-org-agenda-config-add-files.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test-org-agenda-config-add-files.el b/tests/test-org-agenda-config-add-files.el
index e977cc68..8c6f2a69 100644
--- a/tests/test-org-agenda-config-add-files.el
+++ b/tests/test-org-agenda-config-add-files.el
@@ -7,6 +7,7 @@
;;; Code:
(require 'ert)
+(require 'cl-lib)
(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory))
(require 'testutil-general)
@@ -129,5 +130,16 @@
(should (member "/existing/file.org" org-agenda-files))))
(cj/delete-test-base-dir)))
+(ert-deftest test-org-agenda-config-add-files-boundary-missing-dir-warns-not-errors ()
+ "Boundary: a missing project directory warns and adds nothing, without erroring.
+Previously `directory-files' on a missing dir crashed the agenda build."
+ (let ((org-agenda-files '("/existing/file.org"))
+ (warned nil))
+ (cl-letf (((symbol-function 'display-warning)
+ (lambda (&rest _) (setq warned t))))
+ (cj/add-files-to-org-agenda-files-list "/no/such/cj-agenda/dir/"))
+ (should warned)
+ (should (equal org-agenda-files '("/existing/file.org")))))
+
(provide 'test-org-agenda-config-add-files)
;;; test-org-agenda-config-add-files.el ends here