Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Test/A08time fails if there's no terminal



On Mon 16 Feb 2026, at 22:16, Bart Schaefer wrote:
> Something other than "read -t0.1" is needed for the delay here.

sorry. i guess this should work

dana


diff --git a/Test/A08time.ztst b/Test/A08time.ztst
index 071038d1f..ee4d28c88 100644
--- a/Test/A08time.ztst
+++ b/Test/A08time.ztst
@@ -4,7 +4,8 @@
 
 %prep
 
-  unset TIMEFMT
+  unset TIMEFMT zselect_skip
+  zmodload -s zsh/zselect || zselect_skip='zsh/zselect module not available'
 
 %test
 
@@ -23,30 +24,42 @@
 0:TIMEFMT %*[USE] use millisecond precision
 *?x( <0-9>.<000-999>)(#c3)
 
-  ( TIMEFMT='%nU %nS'; time (read -k3 -t0.1) )
+  if [[ -n $zselect_skip ]]; then
+    ZTST_skip=$zselect_skip
+  else
+    ( TIMEFMT='%nU %nS'; time (zselect -t 10) )
+  fi
 1:TIMEFMT %nU and %nS are limited to microsecond precision
 *?(0|[1-9][0-9]#000)ns (0|[1-9][0-9]#000)ns
 
 # SECONDS (after - before) must be greater than the elapsed time, but not much
 # greater. 25% was picked arbitrarily as something that hopefully will prevent
 # the test from failing on slow machines
-  (
-    typeset -F SECONDS
-    TIMEFMT=%nE
-    a=$SECONDS
-    t=$( (time (read -k3 -t0.1)) 2>&1 )
-    b=$SECONDS
-    s=$(( b - a ))
-    t=$(( ${t%ns}.0 / 10**9 ))
-    echo $s $t $(( s > t )) $(( t > s - (s * 0.25) ))
-  )
+  if [[ -n $zselect_skip ]]; then
+    ZTST_skip=$zselect_skip
+  else
+    (
+      typeset -F SECONDS
+      TIMEFMT=%nE
+      a=$SECONDS
+      t=$( (time (zselect -t 10)) 2>&1 )
+      b=$SECONDS
+      s=$(( b - a ))
+      t=$(( ${t%ns}.0 / 10**9 ))
+      echo $s $t $(( s > t )) $(( t > s - (s * 0.25) ))
+    )
+  fi
 0:`time' elapsed time matches SECONDS
 *>[0-9.]## [0-9.]## 1 1
 
 # Again, the wide range here is an attempt to prevent this test from failing on
 # slow machines. We don't care about the exact time, just that it's vaguely sane
 # and that each representation has the same basis
-  ( TIMEFMT='%E %mE %uE %nE %*E'; time (read -k3 -t0.1) )
+  if [[ -n $zselect_skip ]]; then
+    ZTST_skip=$zselect_skip
+  else
+    ( TIMEFMT='%E %mE %uE %nE %*E'; time (zselect -t 10) )
+  fi
 1:TIMEFMT elapsed time values
 *?0.<10-50>s <10-500>ms <100000-500000>us <100000000-500000000>ns 0.<100-500>
 




Messages sorted by: Reverse Date, Date, Thread, Author