Skip to content

Commit a8a5d25

Browse files
Eric Wonggitster
authored andcommitted
git svn: migrate tests to use lib-httpd
This allows us to use common test infrastructure and parallelize the tests. For now, GIT_SVN_TEST_HTTPD=true needs to be set to enable the SVN HTTP tests because we reuse the same test cases for both file:// and http:// SVN repositories. SVN_HTTPD_PORT is no longer honored. Tested under Apache 2.2 and 2.4 on Debian 7.x (wheezy) and 8.x (jessie), respectively. Cc: Clemens Buchacher <drizzd@aon.at> Cc: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7b232ad commit a8a5d25

File tree

7 files changed

+30
-86
lines changed

7 files changed

+30
-86
lines changed

t/lib-git-svn.sh

Lines changed: 16 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -68,81 +68,22 @@ svn_cmd () {
6868
svn "$orig_svncmd" --config-dir "$svnconf" "$@"
6969
}
7070

71-
prepare_httpd () {
72-
for d in \
73-
"$SVN_HTTPD_PATH" \
74-
/usr/sbin/apache2 \
75-
/usr/sbin/httpd \
76-
; do
77-
if test -f "$d"
78-
then
79-
SVN_HTTPD_PATH="$d"
80-
break
81-
fi
82-
done
83-
if test -z "$SVN_HTTPD_PATH"
84-
then
85-
echo >&2 '*** error: Apache not found'
86-
return 1
87-
fi
88-
for d in \
89-
"$SVN_HTTPD_MODULE_PATH" \
90-
/usr/lib/apache2/modules \
91-
/usr/libexec/apache2 \
92-
; do
93-
if test -d "$d"
94-
then
95-
SVN_HTTPD_MODULE_PATH="$d"
96-
break
97-
fi
98-
done
99-
if test -z "$SVN_HTTPD_MODULE_PATH"
100-
then
101-
echo >&2 '*** error: Apache module dir not found'
102-
return 1
103-
fi
104-
if test ! -f "$SVN_HTTPD_MODULE_PATH/mod_dav_svn.so"
105-
then
106-
echo >&2 '*** error: Apache module "mod_dav_svn" not found'
107-
return 1
108-
fi
109-
110-
repo_base_path="${1-svn}"
111-
mkdir "$GIT_DIR"/logs
112-
113-
cat > "$GIT_DIR/httpd.conf" <<EOF
114-
ServerName "git svn test"
115-
ServerRoot "$GIT_DIR"
116-
DocumentRoot "$GIT_DIR"
117-
PidFile "$GIT_DIR/httpd.pid"
118-
LockFile logs/accept.lock
119-
Listen 127.0.0.1:$SVN_HTTPD_PORT
120-
LoadModule dav_module $SVN_HTTPD_MODULE_PATH/mod_dav.so
121-
LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so
122-
<Location /$repo_base_path>
123-
DAV svn
124-
SVNPath "$rawsvnrepo"
125-
</Location>
126-
EOF
127-
}
128-
129-
start_httpd () {
130-
if test -z "$SVN_HTTPD_PORT"
131-
then
132-
echo >&2 'SVN_HTTPD_PORT is not defined!'
133-
return
134-
fi
135-
136-
prepare_httpd "$1" || return 1
137-
138-
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start
139-
svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path"
140-
}
141-
142-
stop_httpd () {
143-
test -z "$SVN_HTTPD_PORT" && return
144-
test ! -f "$GIT_DIR/httpd.conf" && return
145-
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k stop
71+
maybe_start_httpd () {
72+
loc=${1-svn}
73+
74+
test_tristate GIT_SVN_TEST_HTTPD
75+
case $GIT_SVN_TEST_HTTPD in
76+
true)
77+
. "$TEST_DIRECTORY"/lib-httpd.sh
78+
LIB_HTTPD_SVN="$loc"
79+
start_httpd
80+
;;
81+
*)
82+
stop_httpd () {
83+
: noop
84+
}
85+
;;
86+
esac
14687
}
14788

14889
convert_to_rev_db () {

t/lib-httpd.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# LIB_HTTPD_MODULE_PATH web server modules path
2525
# LIB_HTTPD_PORT listening port
2626
# LIB_HTTPD_DAV enable DAV
27-
# LIB_HTTPD_SVN enable SVN
27+
# LIB_HTTPD_SVN enable SVN at given location (e.g. "svn")
2828
# LIB_HTTPD_SSL enable SSL
2929
#
3030
# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
@@ -162,8 +162,10 @@ prepare_httpd() {
162162
if test -n "$LIB_HTTPD_SVN"
163163
then
164164
HTTPD_PARA="$HTTPD_PARA -DSVN"
165-
rawsvnrepo="$HTTPD_ROOT_PATH/svnrepo"
166-
svnrepo="http://127.0.0.1:$LIB_HTTPD_PORT/svn"
165+
LIB_HTTPD_SVNPATH="$rawsvnrepo"
166+
svnrepo="http://127.0.0.1:$LIB_HTTPD_PORT/"
167+
svnrepo="$svnrepo$LIB_HTTPD_SVN"
168+
export LIB_HTTPD_SVN LIB_HTTPD_SVNPATH
167169
fi
168170
fi
169171
}

t/lib-httpd/apache.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ RewriteRule ^/half-auth-complete/ - [E=AUTHREQUIRED:yes]
192192
<IfDefine SVN>
193193
LoadModule dav_svn_module modules/mod_dav_svn.so
194194

195-
<Location /svn>
195+
<Location /${LIB_HTTPD_SVN}>
196196
DAV svn
197-
SVNPath svnrepo
197+
SVNPath "${LIB_HTTPD_SVNPATH}"
198198
</Location>
199199
</IfDefine>

t/t9115-git-svn-dcommit-funky-renames.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ test_description='git svn dcommit can commit renames of files with ugly names'
88
. ./lib-git-svn.sh
99

1010
test_expect_success 'load repository with strange names' '
11-
svnadmin load -q "$rawsvnrepo" < "$TEST_DIRECTORY"/t9115/funky-names.dump &&
12-
start_httpd gtk+
13-
'
11+
svnadmin load -q "$rawsvnrepo" <"$TEST_DIRECTORY"/t9115/funky-names.dump
12+
'
13+
14+
maybe_start_httpd gtk+
1415

1516
test_expect_success 'init and fetch repository' '
1617
git svn init "$svnrepo" &&

t/t9118-git-svn-funky-branch-names.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test_expect_success 'setup svnrepo' '
3232
"$svnrepo/pr ject/branches/trailing_dotlock.lock" &&
3333
svn_cmd cp -m "reflog" "$svnrepo/pr ject/trunk" \
3434
"$svnrepo/pr ject/branches/not-a@{0}reflog@" &&
35-
start_httpd
35+
maybe_start_httpd
3636
'
3737

3838
# SVN 1.7 will truncate "not-a%40{0]" to just "not-a".

t/t9120-git-svn-clone-with-percent-escapes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_expect_success 'setup svnrepo' '
1515
svn_cmd cp -m "tag" "$svnrepo/pr ject/trunk" \
1616
"$svnrepo/pr ject/tags/v1" &&
1717
rm -rf project &&
18-
start_httpd
18+
maybe_start_httpd
1919
'
2020

2121
test_expect_success 'test clone with percent escapes' '

t/t9142-git-svn-shallow-clone.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test_expect_success 'setup test repository' '
1818
svn_cmd add foo &&
1919
svn_cmd commit -m "add foo"
2020
) &&
21-
start_httpd
21+
maybe_start_httpd
2222
'
2323

2424
test_expect_success 'clone trunk with "-r HEAD"' '

0 commit comments

Comments
 (0)