Ihor Radchenko <[email protected]> writes: >> (ert-deftest ob-tangle/bibtex () >> "Tangle BibTeX into a `.bib' file." >> - (let ((file (make-temp-file "org-tangle-" nil ".org")) >> - (bib "@Misc{example, >> + (let ((bib "@Misc{example, >> ... >> - (unwind-protect >> - (with-current-buffer (find-file-noselect file) >> - (insert (format "#+begin_src bibtex :tangle yes >> + (org-test-with-temp-text-in-file >> + (format "#+begin_src bibtex :tangle yes >> %s >> -#+end_src" >> ... >> - (let ((bib-file >> - (if (fboundp 'file-name-with-extension) >> - (file-name-with-extension file "bib") >> - ;; Emacs <28 >> - (concat (file-name-sans-extension file) "." "bib")))) >> - (should (file-exists-p bib-file)) >> - (should (string= (string-trim (org-file-contents bib-file)) >> - bib)))) >> - (delete-file file)))) > > This won't work. FILE variable is used to derive the tangled file name. > Same for some clauses you changed in test-org-capture/org-capture-expand-olp.
The macro `org-test-with-temp-text-in-file' exposes the variable FILE. So my change means the bibtex test is now run with the file "/tmp/tmp-orgtest/org-testrQUDO1" instead of "/tmp/tmp-orgtest/org-tangle-ZEuUAL.org". The org capture test already makes a temp file called "org-test" so the file name will remain the same. However, the file will now have the major mode `org-mode' activated where it wouldn't have before. All the tests pass on multiple versions of Emacs. Which of the following options would you like me to do? 1. Change `org-test-with-temp-text-in-file' to not expose the variables `file', `inside-text', and `buffer' as that is bound to lead to confusing behavior. 2. Change the patch to completely maintain existing behavior and simply kill the offending buffers. 3. [fill in the blank]
