Skip to content

Commit 8901fd2

Browse files
committed
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.
1 parent 192742c commit 8901fd2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

testing/lisp/test-ox.el

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,32 @@ variable, and communication channel under `info'."
6363

6464
(ert-deftest test-org-export/org-export-copy-buffer ()
6565
"Test `org-export-copy-buffer' specifications."
66-
;; The buffer copy must not cause overwriting the original file
67-
;; buffer under any circumstances.
66+
;; The copy must not overwrite the original file.
6867
(org-test-with-temp-text-in-file
6968
"* Heading"
7069
(let ((file (buffer-file-name)))
7170
(with-current-buffer (org-export-copy-buffer)
72-
(insert "This must not go into actual file.")
71+
(insert "This must not go into the original file.")
7372
(save-buffer)
7473
(should
7574
(equal
7675
"* Heading"
7776
(with-temp-buffer
7877
(insert-file-contents file)
79-
(buffer-string))))))))
78+
(buffer-string)))))))
79+
;; The copy must not show when re-opening the original file.
80+
(org-test-with-temp-text-in-file
81+
"* Heading"
82+
(let ((file (buffer-file-name))
83+
(buffer-copy (generate-new-buffer " *Org export copy*")))
84+
(org-export-with-buffer-copy
85+
:to-buffer buffer-copy
86+
(insert "This must not show as the original file.")
87+
(save-buffer))
88+
;; Unassign the original buffer from file.
89+
(setq buffer-file-name nil)
90+
(should-not
91+
(equal buffer-copy (get-file-buffer file))))))
8092

8193
(ert-deftest test-org-export/bind-keyword ()
8294
"Test reading #+BIND: keywords."

0 commit comments

Comments
 (0)