54203: replace "read -t" with "zselect" for "make check" with no terminal

This commit is contained in:
dana
2026-02-21 13:40:37 -08:00
committed by Bart Schaefer
parent 09e1b5631d
commit 52775e448d

View File

@@ -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>