:text STRING If non-nil, pass STRING to `make-temp-file' as
the TEXT argument.
+:coding CODING If non-nil, bind `coding-system-for-write' to CODING
+ when executing BODY. This is handy when STRING includes
+ non-ASCII characters or the temporary file must have a
+ specific encoding or end-of-line format.
+
See also `ert-with-temp-directory'."
(declare (indent 1) (debug (symbolp body)))
(cl-check-type name symbol)
- (let (keyw prefix suffix directory text extra-keywords)
+ (let (keyw prefix suffix directory text extra-keywords coding)
(while (keywordp (setq keyw (car body)))
(setq body (cdr body))
(pcase keyw
(:suffix (setq suffix (pop body)))
(:directory (setq directory (pop body)))
(:text (setq text (pop body)))
+ (:coding (setq coding (pop body)))
(_ (push keyw extra-keywords) (pop body))))
(when extra-keywords
(error "Invalid keywords: %s" (mapconcat #'symbol-name extra-keywords " ")))
(suffix (or suffix ert-temp-file-suffix
(ert--with-temp-file-generate-suffix
(or (macroexp-file-name) buffer-file-name)))))
- `(let* ((,temp-file (,(if directory 'file-name-as-directory 'identity)
+ `(let* ((coding-system-for-write ,(or coding coding-system-for-write))
+ (,temp-file (,(if directory 'file-name-as-directory 'identity)
(make-temp-file ,prefix ,directory ,suffix ,text)))
(,name ,(if directory
`(file-name-as-directory ,temp-file)
"Test that we can undigest a RFC 934 digest."
(ert-with-temp-file file
:text rmail-rfc934-digest
+ ;; Rmail reads mbox files literally, so we must make sure the
+ ;; temporary mbox file has Unix-style EOLs.
+ :coding 'undecided-unix
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 4))
:expected-result :failed
(ert-with-temp-file file
:text rmail-rfc1153-digest-strict
+ ;; Rmail reads mbox files literally, so we must make sure the
+ ;; temporary mbox file has Unix-style EOLs.
+ :coding 'undecided-unix
(rmail file)
(should
(ignore-errors
"Test that we can undigest a RFC 1153 with a Subject header in its footer."
(ert-with-temp-file file
:text rmail-rfc1153-digest-less-strict
+ ;; Rmail reads mbox files literally, so we must make sure the
+ ;; temporary mbox file has Unix-style EOLs.
+ :coding 'undecided-unix
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 5))
"Test that we can undigest a sloppy RFC 1153 digest."
(ert-with-temp-file file
:text rmail-rfc1153-digest-sloppy
+ ;; Rmail reads mbox files literally, so we must make sure the
+ ;; temporary mbox file has Unix-style EOLs.
+ :coding 'undecided-unix
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 5))
:expected-result :failed
(ert-with-temp-file file
:text rmail-rfc1521-mime-digest
+ ;; Rmail reads mbox files literally, so we must make sure the
+ ;; temporary mbox file has Unix-style EOLs.
+ :coding 'undecided-unix
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 3))
"Test that we can undigest a digest inside a multipart/mixed digest."
(ert-with-temp-file file
:text rmail-multipart-mixed-digest
+ ;; Rmail reads mbox files literally, so we must make sure the
+ ;; temporary mbox file has Unix-style EOLs.
+ :coding 'undecided-unix
(rmail file)
(undigestify-rmail-message)
(should (= rmail-total-messages 4))