t9400: Add test cases for config file handling
[git/gitweb.git] / t / t9400-git-cvsserver-server.sh
blob1b6343557aa45df66578128382748974b0ee90e0
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 # CONFIG TESTS
52 #--------------
54 test_expect_success 'gitcvs.enabled = false' \
55 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
56 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
57 then
58 echo unexpected cvs success
59 false
60 else
61 true
62 fi &&
63 cat cvs.log | grep -q "GITCVS emulation disabled" &&
64 test ! -d cvswork2'
66 rm -fr cvswork2
67 test_expect_success 'gitcvs.ext.enabled = true' \
68 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
69 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
70 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
71 diff -q cvswork cvswork2'
73 rm -fr cvswork2
74 test_expect_success 'gitcvs.ext.enabled = false' \
75 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
76 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
77 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
78 then
79 echo unexpected cvs success
80 false
81 else
82 true
83 fi &&
84 cat cvs.log | grep -q "GITCVS emulation disabled" &&
85 test ! -d cvswork2'
87 rm -fr cvswork2
88 test_expect_success 'gitcvs.dbname' \
89 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
90 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
91 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
92 diff -q cvswork cvswork2 &&
93 test -f "$SERVERDIR/gitcvs.ext.master.sqlite" &&
94 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"'
96 rm -fr cvswork2
97 test_expect_success 'gitcvs.ext.dbname' \
98 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
99 GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
100 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
101 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
102 diff -q cvswork cvswork2 &&
103 test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" &&
104 test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" &&
105 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"'
108 #------------
109 # CVS UPDATE
110 #------------
112 rm -fr "$SERVERDIR"
113 cd "$WORKDIR" &&
114 git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
115 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
116 GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
117 exit 1
119 test_expect_success 'cvs update (create new file)' \
120 'echo testfile1 >testfile1 &&
121 git add testfile1 &&
122 git commit -q -m "Add testfile1" &&
123 git push gitcvs.git >/dev/null &&
124 cd cvswork &&
125 GIT_CONFIG="$git_config" cvs -Q update &&
126 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
127 diff -q testfile1 ../testfile1'
129 cd "$WORKDIR"
130 test_expect_success 'cvs update (update existing file)' \
131 'echo line 2 >>testfile1 &&
132 git add testfile1 &&
133 git commit -q -m "Append to testfile1" &&
134 git push gitcvs.git >/dev/null &&
135 cd cvswork &&
136 GIT_CONFIG="$git_config" cvs -Q update &&
137 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
138 diff -q testfile1 ../testfile1'
140 cd "$WORKDIR"
141 #TODO: cvsserver doesn't support update w/o -d
142 test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" \
143 'mkdir test &&
144 echo >test/empty &&
145 git add test &&
146 git commit -q -m "Single Subdirectory" &&
147 git push gitcvs.git >/dev/null &&
148 cd cvswork &&
149 GIT_CONFIG="$git_config" cvs -Q update &&
150 test ! -d test'
152 cd "$WORKDIR"
153 test_expect_success 'cvs update (subdirectories)' \
154 '(for dir in A A/B A/B/C A/D E; do
155 mkdir $dir &&
156 echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
157 git add $dir;
158 done) &&
159 git commit -q -m "deep sub directory structure" &&
160 git push gitcvs.git >/dev/null &&
161 cd cvswork &&
162 GIT_CONFIG="$git_config" cvs -Q update -d &&
163 (for dir in A A/B A/B/C A/D E; do
164 filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
165 if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
166 diff -q "$dir/$filename" "../$dir/$filename"; then
168 else
169 echo >failure
171 done) &&
172 test ! -f failure'
174 cd "$WORKDIR"
175 test_expect_success 'cvs update (delete file)' \
176 'git rm testfile1 &&
177 git commit -q -m "Remove testfile1" &&
178 git push gitcvs.git >/dev/null &&
179 cd cvswork &&
180 GIT_CONFIG="$git_config" cvs -Q update &&
181 test -z "$(grep testfile1 CVS/Entries)" &&
182 test ! -f testfile1'
184 cd "$WORKDIR"
185 test_expect_success 'cvs update (re-add deleted file)' \
186 'echo readded testfile >testfile1 &&
187 git add testfile1 &&
188 git commit -q -m "Re-Add testfile1" &&
189 git push gitcvs.git >/dev/null &&
190 cd cvswork &&
191 GIT_CONFIG="$git_config" cvs -Q update &&
192 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
193 diff -q testfile1 ../testfile1'
195 test_done