From e049561a3b6fcb6e296ece6828fd8d4485cb7c44 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 17 Jul 2025 10:26:17 +0300 Subject: [PATCH] ; * test/src/fileio-tests.el (fileio-tests--read-directory): New test. (cherry picked from commit 29324fd0fa3755028466966b6eeb3cd0df1b442f) --- test/src/fileio-tests.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index b6302c35fee..066dd901434 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -195,6 +195,21 @@ Also check that an encoding error can appear in a symlink." (insert-file-contents "/dev/urandom" nil nil 10) (should (= (buffer-size) 10)))) +(ert-deftest fileio-tests--read-directory () + "Make sure insertring a directory fails with a platform-independent error." + (ert-with-temp-directory dir + (let* ((dir-name (directory-file-name dir)) + (err (should-error (insert-file-contents dir-name))) + (desc-string + (if (eq system-type 'windows-nt) + "Opening input file" + "Read error"))) + (should (equal err + (list 'file-error + desc-string + "Is a directory" + dir-name)))))) + (defun fileio-tests--identity-expand-handler (_ file &rest _) file) (put 'fileio-tests--identity-expand-handler 'operations '(expand-file-name)) -- 2.39.5