git-submodule: clone during update, not during init
[git/dscho.git] / t / t9400-git-cvsserver-server.sh
blobe9ef315173f9596212d9104587486315603b2b51
1 #!/bin/sh
3 # Copyright (c) 2007 Frank Lichtenheld
6 test_description='git-cvsserver access
8 tests read access to a git repository with the
9 cvs CLI client via git-cvsserver server'
11 . ./test-lib.sh
13 cvs >/dev/null 2>&1
14 if test $? -ne 1
15 then
16 test_expect_success 'skipping git-cvsserver tests, cvs not found' :
17 test_done
18 exit
20 perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
21 test_expect_success 'skipping git-cvsserver tests, Perl SQLite interface unavailable' :
22 test_done
23 exit
26 unset GIT_DIR GIT_CONFIG
27 WORKDIR=$(pwd)
28 SERVERDIR=$(pwd)/gitcvs.git
29 git_config="$SERVERDIR/config"
30 CVSROOT=":fork:$SERVERDIR"
31 CVSWORK="$(pwd)/cvswork"
32 CVS_SERVER=git-cvsserver
33 export CVSROOT CVS_SERVER
35 rm -rf "$CVSWORK" "$SERVERDIR"
36 echo >empty &&
37 git add empty &&
38 git commit -q -m "First Commit" &&
39 git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
40 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
41 GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
42 exit 1
44 # note that cvs doesn't accept absolute pathnames
45 # as argument to co -d
46 test_expect_success 'basic checkout' \
47 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
48 test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
50 #------------------------
51 # PSERVER AUTHENTICATION
52 #------------------------
54 cat >request-anonymous <<EOF
55 BEGIN AUTH REQUEST
56 $SERVERDIR
57 anonymous
59 END AUTH REQUEST
60 EOF
62 cat >request-git <<EOF
63 BEGIN AUTH REQUEST
64 $SERVERDIR
65 git
67 END AUTH REQUEST
68 EOF
70 cat >login-anonymous <<EOF
71 BEGIN VERIFICATION REQUEST
72 $SERVERDIR
73 anonymous
75 END VERIFICATION REQUEST
76 EOF
78 cat >login-git <<EOF
79 BEGIN VERIFICATION REQUEST
80 $SERVERDIR
81 git
83 END VERIFICATION REQUEST
84 EOF
86 test_expect_success 'pserver authentication' \
87 'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
88 tail -n1 log | grep -q "^I LOVE YOU$"'
90 test_expect_success 'pserver authentication failure (non-anonymous user)' \
91 'if cat request-git | git-cvsserver pserver >log 2>&1
92 then
93 false
94 else
95 true
96 fi &&
97 tail -n1 log | grep -q "^I HATE YOU$"'
99 test_expect_success 'pserver authentication (login)' \
100 'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
101 tail -n1 log | grep -q "^I LOVE YOU$"'
103 test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
104 'if cat login-git | git-cvsserver pserver >log 2>&1
105 then
106 false
107 else
108 true
109 fi &&
110 tail -n1 log | grep -q "^I HATE YOU$"'
113 #--------------
114 # CONFIG TESTS
115 #--------------
117 test_expect_success 'gitcvs.enabled = false' \
118 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
119 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
120 then
121 echo unexpected cvs success
122 false
123 else
124 true
125 fi &&
126 cat cvs.log | grep -q "GITCVS emulation disabled" &&
127 test ! -d cvswork2'
129 rm -fr cvswork2
130 test_expect_success 'gitcvs.ext.enabled = true' \
131 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
132 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
133 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
134 diff -q cvswork cvswork2'
136 rm -fr cvswork2
137 test_expect_success 'gitcvs.ext.enabled = false' \
138 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
139 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
140 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
141 then
142 echo unexpected cvs success
143 false
144 else
145 true
146 fi &&
147 cat cvs.log | grep -q "GITCVS emulation disabled" &&
148 test ! -d cvswork2'
150 rm -fr cvswork2
151 test_expect_success 'gitcvs.dbname' \
152 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
153 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
154 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
155 diff -q cvswork cvswork2 &&
156 test -f "$SERVERDIR/gitcvs.ext.master.sqlite" &&
157 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"'
159 rm -fr cvswork2
160 test_expect_success 'gitcvs.ext.dbname' \
161 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
162 GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
163 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
164 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
165 diff -q cvswork cvswork2 &&
166 test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" &&
167 test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" &&
168 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"'
171 #------------
172 # CVS UPDATE
173 #------------
175 rm -fr "$SERVERDIR"
176 cd "$WORKDIR" &&
177 git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
178 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
179 GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
180 exit 1
182 test_expect_success 'cvs update (create new file)' \
183 'echo testfile1 >testfile1 &&
184 git add testfile1 &&
185 git commit -q -m "Add testfile1" &&
186 git push gitcvs.git >/dev/null &&
187 cd cvswork &&
188 GIT_CONFIG="$git_config" cvs -Q update &&
189 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
190 diff -q testfile1 ../testfile1'
192 cd "$WORKDIR"
193 test_expect_success 'cvs update (update existing file)' \
194 'echo line 2 >>testfile1 &&
195 git add testfile1 &&
196 git commit -q -m "Append to testfile1" &&
197 git push gitcvs.git >/dev/null &&
198 cd cvswork &&
199 GIT_CONFIG="$git_config" cvs -Q update &&
200 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
201 diff -q testfile1 ../testfile1'
203 cd "$WORKDIR"
204 #TODO: cvsserver doesn't support update w/o -d
205 test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" \
206 'mkdir test &&
207 echo >test/empty &&
208 git add test &&
209 git commit -q -m "Single Subdirectory" &&
210 git push gitcvs.git >/dev/null &&
211 cd cvswork &&
212 GIT_CONFIG="$git_config" cvs -Q update &&
213 test ! -d test'
215 cd "$WORKDIR"
216 test_expect_success 'cvs update (subdirectories)' \
217 '(for dir in A A/B A/B/C A/D E; do
218 mkdir $dir &&
219 echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
220 git add $dir;
221 done) &&
222 git commit -q -m "deep sub directory structure" &&
223 git push gitcvs.git >/dev/null &&
224 cd cvswork &&
225 GIT_CONFIG="$git_config" cvs -Q update -d &&
226 (for dir in A A/B A/B/C A/D E; do
227 filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
228 if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
229 diff -q "$dir/$filename" "../$dir/$filename"; then
231 else
232 echo >failure
234 done) &&
235 test ! -f failure'
237 cd "$WORKDIR"
238 test_expect_success 'cvs update (delete file)' \
239 'git rm testfile1 &&
240 git commit -q -m "Remove testfile1" &&
241 git push gitcvs.git >/dev/null &&
242 cd cvswork &&
243 GIT_CONFIG="$git_config" cvs -Q update &&
244 test -z "$(grep testfile1 CVS/Entries)" &&
245 test ! -f testfile1'
247 cd "$WORKDIR"
248 test_expect_success 'cvs update (re-add deleted file)' \
249 'echo readded testfile >testfile1 &&
250 git add testfile1 &&
251 git commit -q -m "Re-Add testfile1" &&
252 git push gitcvs.git >/dev/null &&
253 cd cvswork &&
254 GIT_CONFIG="$git_config" cvs -Q update &&
255 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
256 diff -q testfile1 ../testfile1'
258 cd "$WORKDIR"
259 test_expect_success 'cvs update (merge)' \
260 'echo Line 0 >expected &&
261 for i in 1 2 3 4 5 6 7
263 echo Line $i >>merge
264 echo Line $i >>expected
265 done &&
266 echo Line 8 >>expected &&
267 git add merge &&
268 git commit -q -m "Merge test (pre-merge)" &&
269 git push gitcvs.git >/dev/null &&
270 cd cvswork &&
271 GIT_CONFIG="$git_config" cvs -Q update &&
272 test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" &&
273 diff -q merge ../merge &&
274 ( echo Line 0; cat merge ) >merge.tmp &&
275 mv merge.tmp merge &&
276 cd "$WORKDIR" &&
277 echo Line 8 >>merge &&
278 git add merge &&
279 git commit -q -m "Merge test (merge)" &&
280 git push gitcvs.git >/dev/null &&
281 cd cvswork &&
282 sleep 1 && touch merge &&
283 GIT_CONFIG="$git_config" cvs -Q update &&
284 diff -q merge ../expected'
286 cd "$WORKDIR"
288 cat >expected.C <<EOF
289 <<<<<<< merge.mine
290 Line 0
291 =======
292 LINE 0
293 >>>>>>> merge.3
296 for i in 1 2 3 4 5 6 7 8
298 echo Line $i >>expected.C
299 done
301 test_expect_success 'cvs update (conflict merge)' \
302 '( echo LINE 0; cat merge ) >merge.tmp &&
303 mv merge.tmp merge &&
304 git add merge &&
305 git commit -q -m "Merge test (conflict)" &&
306 git push gitcvs.git >/dev/null &&
307 cd cvswork &&
308 GIT_CONFIG="$git_config" cvs -Q update &&
309 diff -q merge ../expected.C'
311 cd "$WORKDIR"
312 test_expect_success 'cvs update (-C)' \
313 'cd cvswork &&
314 GIT_CONFIG="$git_config" cvs -Q update -C &&
315 diff -q merge ../merge'
317 cd "$WORKDIR"
318 test_expect_success 'cvs update (merge no-op)' \
319 'echo Line 9 >>merge &&
320 cp merge cvswork/merge &&
321 git add merge &&
322 git commit -q -m "Merge test (no-op)" &&
323 git push gitcvs.git >/dev/null &&
324 cd cvswork &&
325 sleep 1 && touch merge &&
326 GIT_CONFIG="$git_config" cvs -Q update &&
327 diff -q merge ../merge'
329 test_done