Re: [PATCH] tests: fix -nt test on low-resolution file systems

dana <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
On Wed 6 May 2026, at 00:26, dana wrote:
> this should make it work everywhere

no. i realised that the -nt test will still fail on systems that skip
the -N one

here's my third attempt. this should eliminate the 2s delay entirely on
most systems

dana


diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 3910f705f..bc565e8b6 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -142,14 +142,23 @@
 
 # can't be bothered with -S
 
-  print -ru $ZTST_fd 'This test may take two seconds...'
-  touch $newnewnew
-  if (( isnfs )); then
+  zmodload -s zsh/datetime && {
+    t= &&
+    strftime -s t %m%d%H%M.%S $(( EPOCHSECONDS + 2 )) &&
+    touch -t $t -- $newnewnew &&
+    touch -at $t -- $unmodified
+  } 2> /dev/null || {
+    print -ru $ZTST_fd 'This test will take two seconds...' &&
+    sleep 2 &&
+    touch -- $newnewnew &&
+    touch -a -- $unmodified
+  }
+  if (( $? )); then
+    ZTST_skip='[[ -N file ]] not tested; touch failed'
+  elif (( isnfs )); then
     ZTST_skip="[[ -N file ]] not supported with NFS"
   elif ! zmodload -F zsh/stat b:zstat 2> /dev/null; then
     ZTST_skip='[[ -N file ]] not tested; zsh/stat not available'
-  elif ! { sleep 2; touch -a $unmodified 2> /dev/null }; then
-    ZTST_skip='[[ -N file ]] not tested; touch failed'
   elif [[ "$(zstat +atime $unmodified)" == "$(zstat +mtime $unmodified)" ]]; then
     ZTST_skip='[[ -N file ]] not supported on this file system'
   else
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.