Fix undigest-tests on MS-Windows
* lisp/emacs-lisp/ert-x.el (ert-with-temp-file): Accept a new keyword argument :coding CODING to use as the encoding when writing initial text to the temporary 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): Force the temporary mbox files to have Unix-style EOL format.
This commit is contained in:
parent
e2e081a476
commit
9a67e83bd6
2 changed files with 27 additions and 2 deletions
|
@ -424,10 +424,15 @@ The following keyword arguments are supported:
|
|||
: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
|
||||
|
@ -435,6 +440,7 @@ See also `ert-with-temp-directory'."
|
|||
(: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 " ")))
|
||||
|
@ -443,7 +449,8 @@ See also `ert-with-temp-directory'."
|
|||
(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)
|
||||
|
|
|
@ -273,6 +273,9 @@ The footer.
|
|||
"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))
|
||||
|
@ -285,6 +288,9 @@ The footer.
|
|||
: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
|
||||
|
@ -300,6 +306,9 @@ The footer.
|
|||
"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))
|
||||
|
@ -310,6 +319,9 @@ The footer.
|
|||
"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))
|
||||
|
@ -324,6 +336,9 @@ The footer.
|
|||
: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))
|
||||
|
@ -334,6 +349,9 @@ The footer.
|
|||
"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))
|
||||
|
|
Loading…
Add table
Reference in a new issue