1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Don't leave temp files behind from undigest-tests

Sadly the "temp" in with-temp-file refers to a buffer, not a file.
* test/lisp/mail/undigest-tests.el (rmail-undigest-test-rfc934-digest)
(rmail-undigest-test-rfc1153-digest-strict)
(rmail-undigest-test-rfc1153-less-strict-digest)
(rmail-undigest-test-rfc1153-sloppy-digest)
(rmail-undigest-test-rfc1521-mime-digest)
(rmail-undigest-test-multipart-mixed-digest):
Delete temporary files at end.
This commit is contained in:
Glenn Morris 2022-05-02 18:26:22 -07:00
parent 952cc28e58
commit 5dfe568cad

View file

@ -271,59 +271,65 @@ The footer.
(ert-deftest rmail-undigest-test-rfc934-digest ()
"Test that we can undigest a RFC 934 digest."
(let ((file (make-temp-file "undigest-test-")))
(with-temp-file file
(insert rmail-rfc934-digest)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 4))
(should (string= (rmail-message-content 2) "Testing the undigester.\n\n"))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n")))))
(unwind-protect
(with-temp-buffer
(insert rmail-rfc934-digest)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 4))
(should (string= (rmail-message-content 2) "Testing the undigester.\n\n"))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n")))
(delete-file file))))
(ert-deftest rmail-undigest-test-rfc1153-digest-strict ()
"Test that we can undigest a strict RFC 1153 digest."
:expected-result :failed
(let ((file (make-temp-file "undigest-test-")))
(with-temp-file file
(insert rmail-rfc1153-digest-strict)
(write-region nil nil file)
(rmail file)
(should
(condition-case nil
(progn
(unwind-protect
(with-temp-buffer
(insert rmail-rfc1153-digest-strict)
(write-region nil nil file)
(rmail file)
(should
(ignore-errors
;; This throws an error, because the Trailer is not recognized
;; as a valid RFC 822 (or later) message.
(undigestify-rmail-message)
(should (string= (rmail-message-content 2) "Testing the undigester.\n\n"))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n"))
t)
(error nil))))))
t)))
(delete-file file))))
(ert-deftest rmail-undigest-test-rfc1153-less-strict-digest ()
"Test that we can undigest a RFC 1153 with a Subject header in its footer."
(let ((file (make-temp-file "undigest-test-")))
(with-temp-file file
(insert rmail-rfc1153-digest-less-strict)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 5))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n\n")))))
(unwind-protect
(with-temp-buffer
(insert rmail-rfc1153-digest-less-strict)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 5))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n\n")))
(delete-file file))))
(ert-deftest rmail-undigest-test-rfc1153-sloppy-digest ()
"Test that we can undigest a sloppy RFC 1153 digest."
(let ((file (make-temp-file "undigest-test-")))
(with-temp-file file
(insert rmail-rfc1153-digest-sloppy)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 5))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n\n")))))
(unwind-protect
(with-temp-buffer
(insert rmail-rfc1153-digest-sloppy)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 5))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n\n")))
(delete-file file))))
;; This fails because `rmail-digest-parse-mime' combines the preamble with the
;; first message of the digest. And then, it doesn't get rid of the last
@ -332,23 +338,27 @@ The footer.
"Test that we can undigest a RFC 1521 MIME digest."
:expected-result :failed
(let ((file (make-temp-file "undigest-test-")))
(with-temp-file file
(insert rmail-rfc1521-mime-digest)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 3))
(should (string= (rmail-message-content 2) "Message one.\n\n"))
(should (string= (rmail-message-content 3) "Message two.\n\n")))))
(unwind-protect
(with-temp-buffer
(insert rmail-rfc1521-mime-digest)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 3))
(should (string= (rmail-message-content 2) "Message one.\n\n"))
(should (string= (rmail-message-content 3) "Message two.\n\n")))
(delete-file file))))
(ert-deftest rmail-undigest-test-multipart-mixed-digest ()
"Test that we can undigest a digest inside a multipart/mixed digest."
(let ((file (make-temp-file "undigest-test-")))
(with-temp-file file
(insert rmail-multipart-mixed-digest)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 4))
(should (string= (rmail-message-content 2) "Message one.\n\n"))
(should (string= (rmail-message-content 3) "Message two.\n\n")))))
(unwind-protect
(with-temp-buffer
(insert rmail-multipart-mixed-digest)
(write-region nil nil file)
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 4))
(should (string= (rmail-message-content 2) "Message one.\n\n"))
(should (string= (rmail-message-content 3) "Message two.\n\n")))
(delete-file file))))