From: Eli Zaretskii Date: Sun, 11 May 2025 12:47:17 +0000 (+0300) Subject: Add test for file time-stamp granularity on MS-Windows X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0d29139deeb4b9fbb4fa115992aa60920b01ed25;p=emacs.git Add test for file time-stamp granularity on MS-Windows * test/src/fileio-tests.el (fileio-tests-w32-time-stamp-granularity): New test. (cherry picked from commit 7d84ffc2ded59a1d32b902cf7487a6486e0d9869) --- diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index c2938c4900e..13cc5de29e8 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -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