]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix image-dired-util-tests on MS-Windows
authorEli Zaretskii <eliz@gnu.org>
Thu, 27 Jul 2023 07:28:43 +0000 (10:28 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 27 Jul 2023 07:28:43 +0000 (10:28 +0300)
* test/lisp/image/image-dired-util-tests.el
(image-dired-thumb-name/image-dired)
(image-dired-thumb-name/per-directory): Make these tests work on
MS-Windows, where a file name such as "/foo/bar" gets added the
drive letter when passed through 'expand-file-name'.

test/lisp/image/image-dired-util-tests.el

index bd3d65bdd3a52b985e1a113124025c6037af7c70..1f3747a82b1716fa09457927f52209e3d940792c 100644 (file)
       (should (equal
                (file-name-directory (image-dired-thumb-name "foo.jpg"))
                (file-name-directory (image-dired-thumb-name "/tmp/foo.jpg"))))
-      (should (equal (file-name-nondirectory
-                      ;; The checksum is based on the file name.
-                      (image-dired-thumb-name "/some/path/foo.jpg"))
-                     "dc4e6f7068157023e7f2e8362d15bdd2e3ca89e4.jpg"))
+      (should
+       (let* ((test-fn "/some/path/foo.jpg")
+              (thumb-fn (image-dired-thumb-name test-fn)))
+         (equal (file-name-nondirectory thumb-fn)
+                (concat (sha1 (expand-file-name test-fn)) ".jpg"))))
       (should (equal (file-name-extension
                       (image-dired-thumb-name "foo.gif"))
                      "jpg")))))
     (should (equal
              (file-name-nondirectory (image-dired-thumb-name "foo.jpg"))
              (file-name-nondirectory (image-dired-thumb-name "/tmp/foo.jpg"))))
-    (should (equal (file-name-split (image-dired-thumb-name "/tmp/foo.jpg"))
-                   '("" "tmp" ".image-dired" "foo.jpg.thumb.jpg")))
+    ;; The cdr below avoids the system dependency in the car of the
+    ;; list returned by 'file-name-split': it's "" on Posix systems,
+    ;; but the drive letter on MS-Windows.
+    (should (equal (cdr (file-name-split
+                         (image-dired-thumb-name "/tmp/foo.jpg")))
+                   '("tmp" ".image-dired" "foo.jpg.thumb.jpg")))
     (should (equal (file-name-nondirectory
                     (image-dired-thumb-name "foo.jpg"))
                    "foo.jpg.thumb.jpg"))))