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>
Eric Wong committed
Jul 23, 2016 at 04:26 UTC
a8a5d2511871caec259036af95d7dd6287d12925
7 files changed
+30
-86
t/lib-git-svn.sh
+16
-75
@@ -68,81 +68,22 @@ svn_cmd () {
68
svn "$orig_svncmd" --config-dir "$svnconf" "$@"
69
}
70
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
87
}
88
89
convert_to_rev_db () {
t/lib-httpd.sh
+5
-3
@@ -24,7 +24,7 @@
24
# LIB_HTTPD_MODULE_PATH web server modules path
25
# LIB_HTTPD_PORT listening port
26
# LIB_HTTPD_DAV enable DAV
27
-# LIB_HTTPD_SVN enable SVN
27
+# LIB_HTTPD_SVN enable SVN at given location (e.g. "svn")
28
# LIB_HTTPD_SSL enable SSL
29
#
30
# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
@@ -162,8 +162,10 @@ prepare_httpd() {
162
if test -n "$LIB_HTTPD_SVN"
163
then
164
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
169
fi
170
fi
171
}
t/lib-httpd/apache.conf
+2
-2
@@ -192,8 +192,8 @@ RewriteRule ^/half-auth-complete/ - [E=AUTHREQUIRED:yes]
192
<IfDefine SVN>
193
LoadModule dav_svn_module modules/mod_dav_svn.so
194
195
- <Location /svn>
195
+ <Location /${LIB_HTTPD_SVN}>
196
DAV svn
197
- SVNPath svnrepo
197
+ SVNPath "${LIB_HTTPD_SVNPATH}"
198
</Location>
199
</IfDefine>
t/t9115-git-svn-dcommit-funky-renames.sh
+4
-3
@@ -8,9 +8,10 @@ test_description='git svn dcommit can commit renames of files with ugly names'
8
. ./lib-git-svn.sh
9
10
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+
15
16
test_expect_success 'init and fetch repository' '
17
git svn init "$svnrepo" &&
t/t9118-git-svn-funky-branch-names.sh
+1
-1
@@ -32,7 +32,7 @@ test_expect_success 'setup svnrepo' '
32
"$svnrepo/pr ject/branches/trailing_dotlock.lock" &&
33
svn_cmd cp -m "reflog" "$svnrepo/pr ject/trunk" \
34
"$svnrepo/pr ject/branches/not-a@{0}reflog@" &&
35
- start_httpd
35
+ maybe_start_httpd
36
'
37
38
# SVN 1.7 will truncate "not-a%40{0]" to just "not-a".
t/t9120-git-svn-clone-with-percent-escapes.sh
+1
-1
@@ -15,7 +15,7 @@ test_expect_success 'setup svnrepo' '
15
svn_cmd cp -m "tag" "$svnrepo/pr ject/trunk" \
16
"$svnrepo/pr ject/tags/v1" &&
17
rm -rf project &&
18
- start_httpd
18
+ maybe_start_httpd
19
'
20
21
test_expect_success 'test clone with percent escapes' '
t/t9142-git-svn-shallow-clone.sh
+1
-1
@@ -18,7 +18,7 @@ test_expect_success 'setup test repository' '
18
svn_cmd add foo &&
19
svn_cmd commit -m "add foo"
20
) &&
21
- start_httpd
21
+ maybe_start_httpd
22
'
23
24
test_expect_success 'clone trunk with "-r HEAD"' '