summaryrefslogtreecommitdiff
path: root/test/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2026-04-29 18:04:48 +0300
committerEli Zaretskii <eliz@gnu.org>2026-04-29 18:04:48 +0300
commit7017fcc4c5d1737a196c814728fd7516f4f772d2 (patch)
tree584100156da9ab52c682c1fad2b3ee25ca25b516 /test/lisp
parente452c4a59fb88db8eaf7079a7e7967014dc63497 (diff)
; Add new test to files-tests
* test/lisp/files-tests.el (files-tests-directory-files-recursively-w32): New test.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/files-tests.el48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index f3a2bd2df10..1dcd5161ee9 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -696,6 +696,54 @@ unquoted file names."
(tmpdir nospecial-dir t)
(should-error (directory-files-and-attributes nospecial-dir))))
+(ert-deftest files-tests-directory-files-recursively-w32 ()
+ "Test MS-Windows specific features of `directory-files-recursively'."
+ (skip-unless (eq system-type 'windows-nt))
+ (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+ (let ((files-list
+ ;; The list should be in the order that
+ ;; 'directory-files-recursively' returns files and
+ ;; directories.
+ '("Dir/SubDir/SubSubDir/SuBSubFile"
+ "Dir/SubDir/SubSubDir/"
+ "Dir/SubDir/"
+ "Dir/SuBfIlE1"
+ "Dir/sUbFiLe2"
+ "Dir/"
+ "FiLe1"))
+ (fnrel (lambda (fn) (file-relative-name fn tmpdir))))
+ (dolist (file files-list)
+ (if (directory-name-p file)
+ (make-directory (expand-file-name file nospecial-dir) t)
+ (make-empty-file
+ (expand-file-name file tmpdir) t)))
+ ;; Run them through 'directory-file-name' because the list above
+ ;; uses directory names, whereas 'directory-files-recursively'
+ ;; returns their file names.
+ (should (equal (mapcar 'directory-file-name files-list)
+ ;; Make the returned file names relative.
+ (mapcar fnrel
+ (directory-files-recursively tmpdir ".*" t))))
+ ;; Test that 'directory-files-recursively' downcases file names it
+ ;; returns when 'w32-downcase-file-names' is non-nil.
+ (let ((w32-downcase-file-names t))
+ (should (equal (mapcar 'downcase
+ (mapcar 'directory-file-name files-list))
+ (mapcar fnrel
+ (directory-files-recursively tmpdir ".*" t)))))
+ ;; Test that backslashes are mirrored when files are returned.
+ (let* ((tmpdir-with-backslashes
+ (string-replace "/" "\\" (directory-file-name tmpdir)))
+ (nelt 2)
+ (subdir (file-name-concat
+ (concat tmpdir-with-backslashes "\\")
+ (string-replace "/" "\\" (nth nelt files-list)))))
+ (should (equal (mapcar 'directory-file-name
+ (butlast files-list (- (length files-list)
+ nelt)))
+ (mapcar fnrel
+ (directory-files-recursively subdir ".*" t))))))))
+
(ert-deftest files-tests-file-name-non-special-dired-compress-handler ()
;; `dired-compress-file' can get confused by filenames with ":" in
;; them, which causes this to fail on `windows-nt' systems.