From 6ed84c657f4bb7a6427c0c157d69d98542531260 Mon Sep 17 00:00:00 2001 Message-Id: <6ed84c657f4bb7a6427c0c157d69d98542531260.1665297377.git.yantar92@gmail.com> In-Reply-To: References: From: Ihor Radchenko Date: Sun, 9 Oct 2022 14:31:10 +0800 Subject: [PATCH 2/2] Add a regression test for `org-export-with-buffer-copy' * testing/lisp/test-ox.el (test-org-export/org-export-copy-buffer): Make sure that `org-export-with-buffer-copy' does not show up when Emacs is searching for buffers associated with file. --- testing/lisp/test-ox.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 90a9eb3aa..42867919b 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -63,20 +63,32 @@ ;;; Internal Tests (ert-deftest test-org-export/org-export-copy-buffer () "Test `org-export-copy-buffer' specifications." - ;; The buffer copy must not cause overwriting the original file - ;; buffer under any circumstances. + ;; The copy must not overwrite the original file. (org-test-with-temp-text-in-file "* Heading" (let ((file (buffer-file-name))) (with-current-buffer (org-export-copy-buffer) - (insert "This must not go into actual file.") + (insert "This must not go into the original file.") (save-buffer) (should (equal "* Heading" (with-temp-buffer (insert-file-contents file) - (buffer-string)))))))) + (buffer-string))))))) + ;; The copy must not show when re-opening the original file. + (org-test-with-temp-text-in-file + "* Heading" + (let ((file (buffer-file-name)) + (buffer-copy (generate-new-buffer " *Org export copy*"))) + (org-export-with-buffer-copy + :to-buffer buffer-copy + (insert "This must not show as the original file.") + (save-buffer)) + ;; Unassign the original buffer from file. + (setq buffer-file-name nil) + (should-not + (equal buffer-copy (get-file-buffer file)))))) (ert-deftest test-org-export/bind-keyword () "Test reading #+BIND: keywords." -- 2.35.1