Skip to content

Commit faae885

Browse files
committed
Merge branch 'pw/git-p4-tests'
More "git p4" tests. * pw/git-p4-tests: git p4 test: fix badp4dir test git p4 test: split up big t9800 test git p4 test: cleanup_git should make a new $git git p4 test: copy source indeterminate git p4 test: check for error message in failed test git p4 test: rename some "git-p4 command" strings git p4 test: never create default test repo git p4 test: simplify quoting involving TRASH_DIRECTORY git p4 test: use real_path to resolve p4 client symlinks git p4 test: wait longer for p4d to start and test its pid
2 parents f8a9eaf + a0327c0 commit faae885

9 files changed

+574
-433
lines changed

t/lib-git-p4.sh

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# Library code for git p4 tests
33
#
44

5+
# p4 tests never use the top-level repo; always build/clone into
6+
# a subdirectory called "$git"
7+
TEST_NO_CREATE_REPO=NoThanks
8+
59
. ./test-lib.sh
610

711
if ! test_have_prereq PYTHON; then
@@ -27,23 +31,48 @@ export P4CLIENT=client
2731
export P4EDITOR=:
2832

2933
db="$TRASH_DIRECTORY/db"
30-
cli="$TRASH_DIRECTORY/cli"
34+
cli=$(test-path-utils real_path "$TRASH_DIRECTORY/cli")
3135
git="$TRASH_DIRECTORY/git"
3236
pidfile="$TRASH_DIRECTORY/p4d.pid"
3337

3438
start_p4d() {
3539
mkdir -p "$db" "$cli" "$git" &&
40+
rm -f "$pidfile" &&
3641
(
3742
p4d -q -r "$db" -p $P4DPORT &
3843
echo $! >"$pidfile"
3944
) &&
40-
for i in 1 2 3 4 5 ; do
41-
p4 info >/dev/null 2>&1 && break || true &&
42-
echo waiting for p4d to start &&
45+
46+
# This gives p4d a long time to start up, as it can be
47+
# quite slow depending on the machine. Set this environment
48+
# variable to something smaller to fail faster in, say,
49+
# an automated test setup. If the p4d process dies, that
50+
# will be caught with the "kill -0" check below.
51+
i=${P4D_START_PATIENCE:-300}
52+
pid=$(cat "$pidfile")
53+
ready=
54+
while test $i -gt 0
55+
do
56+
# succeed when p4 client commands start to work
57+
if p4 info >/dev/null 2>&1
58+
then
59+
ready=true
60+
break
61+
fi
62+
# fail if p4d died
63+
kill -0 $pid 2>/dev/null || break
64+
echo waiting for p4d to start
4365
sleep 1
44-
done &&
45-
# complain if it never started
46-
p4 info >/dev/null &&
66+
i=$(( $i - 1 ))
67+
done
68+
69+
if test -z "$ready"
70+
then
71+
# p4d failed to start
72+
return 1
73+
fi
74+
75+
# build a client
4776
(
4877
cd "$cli" &&
4978
p4 client -i <<-EOF
@@ -53,6 +82,7 @@ start_p4d() {
5382
View: //depot/... //client/...
5483
EOF
5584
)
85+
return 0
5686
}
5787

5888
kill_p4d() {
@@ -69,5 +99,6 @@ kill_p4d() {
6999
}
70100

71101
cleanup_git() {
72-
rm -rf "$git"
102+
rm -rf "$git" &&
103+
mkdir "$git"
73104
}

0 commit comments

Comments
 (0)