Skip to content

Commit aa5105d

Browse files
committed
t/lib-git-svn: try harder to find a port
As with the previous commits, try harder to find an open port to avoid intermittent failures on busy/shared build systems. By default, we make 3 attempts. This may be overridden by setting GIT_TEST_START_SVNSERVE_TRIES to a different value. Run svnserve in daemon mode and use 'test_atexit' to stop it. This is cleaner than running in the foreground with --listen-once and having to manage the PID ourselves. Signed-off-by: Todd Zullinger <tmz@pobox.com>
1 parent 16750d0 commit aa5105d

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

t/lib-git-svn.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fi
1717
GIT_DIR=$PWD/.git
1818
GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
1919
SVN_TREE=$GIT_SVN_DIR/svn-tree
20+
SVNSERVE_PIDFILE="$PWD"/daemon.pid
2021
test_set_port SVNSERVE_PORT
2122

2223
svn >/dev/null 2>&1
@@ -119,10 +120,35 @@ require_svnserve () {
119120
}
120121

121122
start_svnserve () {
122-
svnserve --listen-port $SVNSERVE_PORT \
123-
--root "$rawsvnrepo" \
124-
--listen-once \
125-
--listen-host 127.0.0.1 &
123+
test_atexit stop_svnserve
124+
125+
i=0
126+
while test $i -lt ${GIT_TEST_START_SVNSERVE_TRIES:-3}
127+
do
128+
say >&3 "Starting svnserve on port $SVNSERVE_PORT ..."
129+
svnserve --listen-port $SVNSERVE_PORT \
130+
--root "$rawsvnrepo" \
131+
--daemon --pid-file="$SVNSERVE_PIDFILE" \
132+
--listen-host 127.0.0.1
133+
ret=$?
134+
# increment port and retry if unsuccessful
135+
if test $ret -ne 0
136+
then
137+
SVNSERVE_PORT=$(($SVNSERVE_PORT + 1))
138+
export SVNSERVE_PORT
139+
else
140+
break
141+
fi
142+
done
143+
}
144+
145+
stop_svnserve () {
146+
say >&3 "Stopping svnserve ..."
147+
SVNSERVE_PID="$(cat "$SVNSERVE_PIDFILE")"
148+
if test -n "$SVNSERVE_PID"
149+
then
150+
kill "$SVNSERVE_PID" 2>/dev/null
151+
fi
126152
}
127153

128154
prepare_utf8_locale () {

t/t9113-git-svn-dcommit-new-file.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ test_expect_success 'create files in new directory with dcommit' "
2828
echo hello > git-new-dir/world &&
2929
git update-index --add git-new-dir/world &&
3030
git commit -m hello &&
31-
start_svnserve &&
3231
git svn dcommit
3332
"
3433

0 commit comments

Comments
 (0)