]> git.eshelyaron.com Git - emacs.git/commitdiff
Add test for file time-stamp granularity on MS-Windows
authorEli Zaretskii <eliz@gnu.org>
Sun, 11 May 2025 12:47:17 +0000 (15:47 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 12 May 2025 19:55:36 +0000 (21:55 +0200)
* test/src/fileio-tests.el
(fileio-tests-w32-time-stamp-granularity): New test.

(cherry picked from commit 7d84ffc2ded59a1d32b902cf7487a6486e0d9869)

test/src/fileio-tests.el

index c2938c4900e16b1f423d5f2fdc85dd9e22d0cf21..13cc5de29e8b1a2afad9998273225dc254702389 100644 (file)
@@ -217,4 +217,23 @@ Also check that an encoding error can appear in a symlink."
   (should-not (file-exists-p "//"))
   (should (file-attributes "//")))
 
+(ert-deftest fileio-tests-w32-time-stamp-granularity ()
+  "Test 100-nsec granularity of file time stamps on MS-Windows."
+  (skip-unless (eq system-type 'windows-nt))
+  ;; FIXME: This only works on NTFS volumes, so should skip the test if
+  ;; not NTFS.  But we don't expose the filesystem type to Lisp.
+  (let ((tfile (make-temp-file "tstamp")))
+    (unwind-protect
+        (progn
+          (set-file-times tfile (encode-time '(59.123456789 15 23 01 02 2025)))
+          (should
+           (equal (format-time-string "%Y/%m/%d %H:%M:%S.%N"
+                                     (file-attribute-modification-time
+                                       (file-attributes tfile)))
+                  ;; Last 2 digits of seconds must be zero due to
+                  ;; 100-nsec resolution of Windows file time stamps.
+                  "2025/02/01 23:15:59.123456700")))
+      (delete-file tfile))))
+
+
 ;;; fileio-tests.el ends here