annotate tests/testlib/wait-on-file @ 52143:dc97e8670dec stable 6.9rc0

doc: register the `config-doc` rst directive This was making the build fail because the directive was unknown.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 28 Oct 2024 16:25:23 +0100
parents 9cfc95e901ec
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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 # 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
15 # 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
16 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
17 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
18 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
19
51947
9cfc95e901ec tests: print the actual timeout value used in `wait-on-file`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49198
diff changeset
20 max_time=$timer
9cfc95e901ec tests: print the actual timeout value used in `wait-on-file`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49198
diff changeset
21
9cfc95e901ec tests: print the actual timeout value used in `wait-on-file`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49198
diff changeset
22 # Scale the timeout to match the sleep steps below, i.e. 1/0.02.
9cfc95e901ec tests: print the actual timeout value used in `wait-on-file`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49198
diff changeset
23 timer=$(( 50 * $timer ))
9cfc95e901ec tests: print the actual timeout value used in `wait-on-file`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49198
diff changeset
24
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
25 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
26 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
27 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
28 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
29 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
30
44780
f727939f3513 tests: use regular POSIX shell
Joerg Sonnenberger <joerg@bec.de>
parents: 44744
diff changeset
31 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
32 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
33 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
34 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
35 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
36 timer=$(( $timer - 1))
44818
9d7d53771e5f tests: fix timer scaling in wait-on-file
Joerg Sonnenberger <joerg@bec.de>
parents: 44780
diff changeset
37 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
38 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
39 if [ "$timer" -le 0 ]; then
51947
9cfc95e901ec tests: print the actual timeout value used in `wait-on-file`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49198
diff changeset
40 echo "file not created after $max_time seconds: $wait_on" >&2
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
41 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
42 fi