[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9a67e83bd6: Fix undigest-tests on MS-Windows
From: |
Eli Zaretskii |
Subject: |
master 9a67e83bd6: Fix undigest-tests on MS-Windows |
Date: |
Sat, 14 May 2022 04:31:51 -0400 (EDT) |
branch: master
commit 9a67e83bd656477e46015c629f3e961e22791a88
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
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.
---
lisp/emacs-lisp/ert-x.el | 11 +++++++++--
test/lisp/mail/undigest-tests.el | 18 ++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 0e412a8d34..c42ce09a1c 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -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)
diff --git a/test/lisp/mail/undigest-tests.el b/test/lisp/mail/undigest-tests.el
index 1c473c4996..d52c9f9c5a 100644
--- a/test/lisp/mail/undigest-tests.el
+++ b/test/lisp/mail/undigest-tests.el
@@ -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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 9a67e83bd6: Fix undigest-tests on MS-Windows,
Eli Zaretskii <=