Skip to content

Commit fba23c8

Browse files
author
Junio C Hamano
committed
Merge branch 'fl/cvsserver'
* fl/cvsserver: cvsserver: Add test cases for git-cvsserver
2 parents 9e6c7e0 + b3b5343 commit fba23c8

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

t/t9400-git-cvsserver-server.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2007 Frank Lichtenheld
4+
#
5+
6+
test_description='git-cvsserver access
7+
8+
tests read access to a git repository with the
9+
cvs CLI client via git-cvsserver server'
10+
11+
. ./test-lib.sh
12+
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
19+
fi
20+
21+
unset GIT_DIR GIT_CONFIG
22+
WORKDIR=$(pwd)
23+
SERVERDIR=$(pwd)/gitcvs.git
24+
CVSROOT=":fork:$SERVERDIR"
25+
CVSWORK=$(pwd)/cvswork
26+
CVS_SERVER=git-cvsserver
27+
export CVSROOT CVS_SERVER
28+
29+
rm -rf "$CVSWORK" "$SERVERDIR"
30+
echo >empty &&
31+
git add empty &&
32+
git commit -q -m "First Commit" &&
33+
git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
34+
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
35+
GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
36+
exit 1
37+
38+
# note that cvs doesn't accept absolute pathnames
39+
# as argument to co -d
40+
test_expect_success 'basic checkout' \
41+
'cvs -Q co -d cvswork master &&
42+
test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
43+
44+
test_expect_success 'cvs update (create new file)' \
45+
'echo testfile1 >testfile1 &&
46+
git add testfile1 &&
47+
git commit -q -m "Add testfile1" &&
48+
git push gitcvs.git >/dev/null &&
49+
cd cvswork &&
50+
cvs -Q update &&
51+
test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
52+
diff -q testfile1 ../testfile1'
53+
54+
cd "$WORKDIR"
55+
test_expect_success 'cvs update (update existing file)' \
56+
'echo line 2 >>testfile1 &&
57+
git add testfile1 &&
58+
git commit -q -m "Append to testfile1" &&
59+
git push gitcvs.git >/dev/null &&
60+
cd cvswork &&
61+
cvs -Q update &&
62+
test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
63+
diff -q testfile1 ../testfile1'
64+
65+
cd "$WORKDIR"
66+
#TODO: cvsserver doesn't support update w/o -d
67+
test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" \
68+
'mkdir test &&
69+
echo >test/empty &&
70+
git add test &&
71+
git commit -q -m "Single Subdirectory" &&
72+
git push gitcvs.git >/dev/null &&
73+
cd cvswork &&
74+
cvs -Q update &&
75+
test ! -d test'
76+
77+
cd "$WORKDIR"
78+
test_expect_success 'cvs update (subdirectories)' \
79+
'(for dir in A A/B A/B/C A/D E; do
80+
mkdir $dir &&
81+
echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
82+
git add $dir;
83+
done) &&
84+
git commit -q -m "deep sub directory structure" &&
85+
git push gitcvs.git >/dev/null &&
86+
cd cvswork &&
87+
cvs -Q update -d &&
88+
(for dir in A A/B A/B/C A/D E; do
89+
filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
90+
if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
91+
diff -q "$dir/$filename" "../$dir/$filename"; then
92+
:
93+
else
94+
echo >failure
95+
fi
96+
done) &&
97+
test ! -f failure'
98+
99+
cd "$WORKDIR"
100+
test_expect_success 'cvs update (delete file)' \
101+
'git rm testfile1 &&
102+
git commit -q -m "Remove testfile1" &&
103+
git push gitcvs.git >/dev/null &&
104+
cd cvswork &&
105+
cvs -Q update &&
106+
test -z "$(grep testfile1 CVS/Entries)" &&
107+
test ! -f testfile1'
108+
109+
cd "$WORKDIR"
110+
test_expect_success 'cvs update (re-add deleted file)' \
111+
'echo readded testfile >testfile1 &&
112+
git add testfile1 &&
113+
git commit -q -m "Re-Add testfile1" &&
114+
git push gitcvs.git >/dev/null &&
115+
cd cvswork &&
116+
cvs -Q update &&
117+
test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
118+
diff -q testfile1 ../testfile1'
119+
120+
test_done

0 commit comments

Comments
 (0)