]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix files-tests on non-Posix systems
authorEli Zaretskii <eliz@gnu.org>
Thu, 5 Aug 2021 17:42:10 +0000 (20:42 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 5 Aug 2021 17:42:10 +0000 (20:42 +0300)
* test/lisp/files-tests.el (files-test-auto-save-name-default)
(files-test-auto-save-name-transform)
(files-test-auto-save-name-unique, files-test-lock-name-default)
(files-test-lock-name-unique): Skip the drive letter in absolute
file names on MS-Windows/MS-DOS when comparing file names against
the expected ones.
(files-tests-file-name-non-special--subprocess): Skip test on
MS-Windows/MS-DOS.

test/lisp/files-tests.el

index a5c8236017781f24d455846b3922982348596cef..640f7d8420ec681f30c7b7f47c40b7924e6d55c5 100644 (file)
@@ -316,7 +316,9 @@ be $HOME."
 
 (ert-deftest files-tests-file-name-non-special--subprocess ()
   "Check that Bug#25949 and Bug#48177 are fixed."
-  (skip-unless (and (executable-find "true") (file-exists-p null-device)))
+  (skip-unless (and (executable-find "true") (file-exists-p null-device)
+                    ;; These systems cannot set date of the null device.
+                    (not (memq system-type '(windows-nt ms-dos)))))
   (let ((default-directory (file-name-quote temporary-file-directory))
         (true (file-name-quote (executable-find "true")))
         (null (file-name-quote null-device)))
@@ -951,40 +953,51 @@ unquoted file names."
 
 (ert-deftest files-test-auto-save-name-default ()
   (with-temp-buffer
-    (let ((auto-save-file-name-transforms nil))
+    (let ((auto-save-file-name-transforms nil)
+          (name-start (if (memq system-type '(windows-nt ms-dos)) 2 nil)))
       (setq buffer-file-name "/tmp/foo.txt")
-      (should (equal (make-auto-save-file-name) "/tmp/#foo.txt#")))))
+      (should (equal (substring (make-auto-save-file-name) name-start)
+                     "/tmp/#foo.txt#")))))
 
 (ert-deftest files-test-auto-save-name-transform ()
   (with-temp-buffer
     (setq buffer-file-name "/tmp/foo.txt")
     (let ((auto-save-file-name-transforms
-           '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" nil))))
-      (should (equal (make-auto-save-file-name) "/var/tmp/#foo.txt#")))))
+           '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" nil)))
+          (name-start (if (memq system-type '(windows-nt ms-dos)) 2 nil)))
+      (should (equal (substring (make-auto-save-file-name) name-start)
+                     "/var/tmp/#foo.txt#")))))
 
 (ert-deftest files-test-auto-save-name-unique ()
   (with-temp-buffer
     (setq buffer-file-name "/tmp/foo.txt")
     (let ((auto-save-file-name-transforms
-           '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" t))))
-      (should (equal (make-auto-save-file-name) "/var/tmp/#!tmp!foo.txt#")))
+           '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" t)))
+          (name-start (if (memq system-type '(windows-nt ms-dos)) 2 nil)))
+      (should (equal (substring (make-auto-save-file-name) name-start)
+                     "/var/tmp/#!tmp!foo.txt#")))
     (let ((auto-save-file-name-transforms
-           '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" sha1))))
-      (should (equal (make-auto-save-file-name)
+           '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" sha1)))
+          (name-start (if (memq system-type '(windows-nt ms-dos)) 2 nil)))
+      (should (equal (substring (make-auto-save-file-name) name-start)
                      "/var/tmp/#b57c5a04f429a83305859d3350ecdab8315a9037#")))))
 
 (ert-deftest files-test-lock-name-default ()
-  (let ((lock-file-name-transforms nil))
-    (should (equal (make-lock-file-name "/tmp/foo.txt") "/tmp/.#foo.txt"))))
+  (let ((lock-file-name-transforms nil)
+        (name-start (if (memq system-type '(windows-nt ms-dos)) 2 nil)))
+    (should (equal (substring (make-lock-file-name "/tmp/foo.txt") name-start)
+                   "/tmp/.#foo.txt"))))
 
 (ert-deftest files-test-lock-name-unique ()
   (let ((lock-file-name-transforms
-         '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" t))))
-    (should (equal (make-lock-file-name "/tmp/foo.txt")
+         '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" t)))
+        (name-start (if (memq system-type '(windows-nt ms-dos)) 2 nil)))
+    (should (equal (substring (make-lock-file-name "/tmp/foo.txt") name-start)
                    "/var/tmp/.#!tmp!foo.txt")))
   (let ((lock-file-name-transforms
-         '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" sha1))))
-    (should (equal (make-lock-file-name "/tmp/foo.txt")
+         '(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" sha1)))
+        (name-start (if (memq system-type '(windows-nt ms-dos)) 2 nil)))
+    (should (equal (substring (make-lock-file-name "/tmp/foo.txt") name-start)
                    "/var/tmp/.#b57c5a04f429a83305859d3350ecdab8315a9037"))))
 
 (ert-deftest files-tests-file-name-non-special-make-directory ()