summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2022-05-14 11:30:54 +0300
committerEli Zaretskii <eliz@gnu.org>2022-05-14 11:30:54 +0300
commit9a67e83bd656477e46015c629f3e961e22791a88 (patch)
tree946c0cbda9c0789b6b4a4cd723e33a97d609c47b /lisp/emacs-lisp
parente2e081a476a2a9309d0870e4c1adda1167c52911 (diff)
downloademacs-9a67e83bd656477e46015c629f3e961e22791a88.tar.gz
emacs-9a67e83bd656477e46015c629f3e961e22791a88.tar.bz2
emacs-9a67e83bd656477e46015c629f3e961e22791a88.zip
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.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/ert-x.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 0e412a8d34e..c42ce09a1c7 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)