Преглед на файлове

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.
Ihor Radchenko преди 2 години
родител
ревизия
8901fd2261
променени са 1 файла, в които са добавени 16 реда и са изтрити 4 реда
  1. 16 4
      testing/lisp/test-ox.el

+ 16 - 4
testing/lisp/test-ox.el

@@ -63,20 +63,32 @@ variable, and communication channel under `info'."
 
 (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."