tests/testlib/wait-on-file
author Matt Harbison <matt_harbison@yahoo.com>
Tue, 06 Sep 2022 15:08:52 -0400
branchstable
changeset 49490 37debd850c16
parent 49198 a68b37524d50
permissions -rwxr-xr-x
packaging: update dulwich to drop the certifi dependency on Windows The presence of `certifi` causes the system certificate store to be ignored, which was reported as a bug against TortoiseHg[1]. It was only pulled in on Windows because of `dulwich`, which was copied from the old TortoiseHg install scripts, in order to support `hg-git`. This version of `dulwich` raises the minimum `urllib3` to a version (1.25) that does certificate verification by default, without the help of `certifi`[2]. We already bundle a newer version of `urllib3`. Note that `certifi` can still be imported from the user site directory, if installed there. But the installer no longer disables the system certificates by default. [1] https://foss.heptapod.net/mercurial/tortoisehg/thg/-/issues/5825 [2] https://github.com/jelmer/dulwich/issues/1025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44780
f727939f3513 tests: use regular POSIX shell
Joerg Sonnenberger <joerg@bec.de>
parents: 44744
diff changeset
     1
#!/bin/sh
44631
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     2
#
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     3
# wait up to TIMEOUT seconds until a WAIT_ON_FILE is created.
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     4
#
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     5
# In addition, this script can create CREATE_FILE once it is ready to wait.
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     6
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     7
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     8
    echo $#
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     9
    echo "USAGE: $0 TIMEOUT WAIT_ON_FILE [CREATE_FILE]"
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    10
fi
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    11
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    12
timer="$1"
44632
82543879b48e testlib: adjust wait-on-file timeout according to the global test timeout
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44631
diff changeset
    13
44818
9d7d53771e5f tests: fix timer scaling in wait-on-file
Joerg Sonnenberger <joerg@bec.de>
parents: 44780
diff changeset
    14
# Scale the timeout to match the sleep steps below, i.e. 1/0.02.
9d7d53771e5f tests: fix timer scaling in wait-on-file
Joerg Sonnenberger <joerg@bec.de>
parents: 44780
diff changeset
    15
timer=$(( 50 * $timer ))
9d7d53771e5f tests: fix timer scaling in wait-on-file
Joerg Sonnenberger <joerg@bec.de>
parents: 44780
diff changeset
    16
# If the test timeout have been extended, also scale the timer relative
9d7d53771e5f tests: fix timer scaling in wait-on-file
Joerg Sonnenberger <joerg@bec.de>
parents: 44780
diff changeset
    17
# to the normal timing.
44632
82543879b48e testlib: adjust wait-on-file timeout according to the global test timeout
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44631
diff changeset
    18
if [ "$HGTEST_TIMEOUT_DEFAULT" -lt "$HGTEST_TIMEOUT" ]; then
44818
9d7d53771e5f tests: fix timer scaling in wait-on-file
Joerg Sonnenberger <joerg@bec.de>
parents: 44780
diff changeset
    19
    timer=$(( ( $timer * $HGTEST_TIMEOUT) / $HGTEST_TIMEOUT_DEFAULT ))
44632
82543879b48e testlib: adjust wait-on-file timeout according to the global test timeout
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44631
diff changeset
    20
fi
82543879b48e testlib: adjust wait-on-file timeout according to the global test timeout
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44631
diff changeset
    21
44631
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    22
wait_on="$2"
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    23
create=""
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    24
if [ $# -eq 3 ]; then
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    25
    create="$3"
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    26
fi
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    27
44780
f727939f3513 tests: use regular POSIX shell
Joerg Sonnenberger <joerg@bec.de>
parents: 44744
diff changeset
    28
if [ -n "$create" ]; then
44631
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    29
    touch "$create"
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    30
    create=""
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    31
fi
49198
a68b37524d50 wait-on-file: properly wait on any files and symlink
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44818
diff changeset
    32
while [ "$timer" -gt 0 ] && !([ -e "$wait_on" ] || [ -L "$wait_on" ]) ; do
44727
694d40416d62 wait-on-file: use proper variable in math
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44726
diff changeset
    33
    timer=$(( $timer - 1))
44818
9d7d53771e5f tests: fix timer scaling in wait-on-file
Joerg Sonnenberger <joerg@bec.de>
parents: 44780
diff changeset
    34
    sleep 0.02
44631
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    35
done
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    36
if [ "$timer" -le 0 ]; then
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    37
    echo "file not created after $1 seconds: $wait_on" >&2
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    38
    exit 1
1ed6293fc31b testlib: add a small scrip to help process to synchronise using file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    39
fi