From d23b10d658539a4646ef015ac2660e1f8c8e7e1b Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Wed, 28 Apr 2021 22:30:04 +0700 Subject: [PATCH] testing/lisp/test-org.el: Refile cache failure testing/lisp/test-org.el (test-org/org-refile-cache): Add expected failure for cache content discrepancy when it is populated by `org-refile' or by `org-goto' (C-u C-c C-j). Usage of just regexp for heading filtering as cache key is unreliable since other settings affects selected entries (`org-refile-target-verify-function') or content of entries (`org-refile-use-outline-path'). However most of users have no chance to notice collision since they do not call both functions interchangeably or have `org-refile-targets' different from the value in `org-goto' code. --- testing/lisp/test-org.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 9f0ede1b9..f44cd76a6 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -6394,6 +6394,30 @@ Paragraph" (org-refile-targets `((nil :level . 1)))) (member (buffer-name) (mapcar #'car (org-refile-get-targets))))))) +(ert-deftest test-org/org-refile-cache () + "Demostrate a cache conflict of `org-goto' and `org-refile'. + +Notice that `org-refile-target-verify-function' can cause more severe +divergence of cache content generated by these functions." + :expected-result :failed + (org-test-with-temp-text "* H1\n** H2\n" + (let ((org-refile-use-cache t) + ;; Regexp serves as cache key, so targets should be the same + ;; as in `org-goto' code. + (org-refile-targets '((nil . (:maxlevel . 5)))) + ;; This value is opposite to the one in `org-goto' code. + (org-refile-use-outline-path nil) + (targets-refile)) + ;; If jumping using `org-refile' (C-u C-c C-w)... + (setq targets-refile (mapcar #'car (org-refile-get-targets))) + (org-refile-cache-clear) + ;; Tune settings to simulate `org-goto' (C-u C-c C-j). + (let ((org-refile-use-outline-path t)) + ;; Value is discarded, call just to populate the cache. + (org-refile-get-targets)) + ;; Targets got by `org-refile'. + (let ((targets-goto (mapcar #'car (org-refile-get-targets)))) + (should (equal targets-refile targets-goto)))))) ;;; Sparse trees -- 2.25.1