comparison tests/testlib/wait-on-file @ 51947:9cfc95e901ec

tests: print the actual timeout value used in `wait-on-file` Previously, it was printing the time passed in, prior to it being scaled up to account for a longer timeout.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 02 Oct 2024 18:30:12 -0400
parents a68b37524d50
children
comparison
equal deleted inserted replaced
51946:d7e61891ab5a 51947:9cfc95e901ec
9 echo "USAGE: $0 TIMEOUT WAIT_ON_FILE [CREATE_FILE]" 9 echo "USAGE: $0 TIMEOUT WAIT_ON_FILE [CREATE_FILE]"
10 fi 10 fi
11 11
12 timer="$1" 12 timer="$1"
13 13
14 # Scale the timeout to match the sleep steps below, i.e. 1/0.02.
15 timer=$(( 50 * $timer ))
16 # If the test timeout have been extended, also scale the timer relative 14 # If the test timeout have been extended, also scale the timer relative
17 # to the normal timing. 15 # to the normal timing.
18 if [ "$HGTEST_TIMEOUT_DEFAULT" -lt "$HGTEST_TIMEOUT" ]; then 16 if [ "$HGTEST_TIMEOUT_DEFAULT" -lt "$HGTEST_TIMEOUT" ]; then
19 timer=$(( ( $timer * $HGTEST_TIMEOUT) / $HGTEST_TIMEOUT_DEFAULT )) 17 timer=$(( ( $timer * $HGTEST_TIMEOUT) / $HGTEST_TIMEOUT_DEFAULT ))
20 fi 18 fi
19
20 max_time=$timer
21
22 # Scale the timeout to match the sleep steps below, i.e. 1/0.02.
23 timer=$(( 50 * $timer ))
21 24
22 wait_on="$2" 25 wait_on="$2"
23 create="" 26 create=""
24 if [ $# -eq 3 ]; then 27 if [ $# -eq 3 ]; then
25 create="$3" 28 create="$3"
32 while [ "$timer" -gt 0 ] && !([ -e "$wait_on" ] || [ -L "$wait_on" ]) ; do 35 while [ "$timer" -gt 0 ] && !([ -e "$wait_on" ] || [ -L "$wait_on" ]) ; do
33 timer=$(( $timer - 1)) 36 timer=$(( $timer - 1))
34 sleep 0.02 37 sleep 0.02
35 done 38 done
36 if [ "$timer" -le 0 ]; then 39 if [ "$timer" -le 0 ]; then
37 echo "file not created after $1 seconds: $wait_on" >&2 40 echo "file not created after $max_time seconds: $wait_on" >&2
38 exit 1 41 exit 1
39 fi 42 fi