1#!/bin/sh
2
3test_description='git cvsimport basic tests'
4. ./test-lib.sh
5
6if ! test_have_prereq PERL; then
7 say 'skipping git cvsimport tests, perl not available'
8 test_done
9fi
10
11CVSROOT=$(pwd)/cvsroot
12export CVSROOT
13unset CVS_SERVER
14# for clean cvsps cache
15HOME=$(pwd)
16export HOME
17
18if ! type cvs >/dev/null 2>&1
19then
20 say 'skipping cvsimport tests, cvs not found'
21 test_done
22fi
23
24cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
25case "$cvsps_version" in
262.1 | 2.2*)
27 ;;
28'')
29 say 'skipping cvsimport tests, cvsps not found'
30 test_done
31 ;;
32*)
33 say 'skipping cvsimport tests, unsupported cvsps version'
34 test_done
35 ;;
36esac
37
38test_expect_success 'setup cvsroot' 'cvs init'
39
40test_expect_success 'setup a cvs module' '
41
42 mkdir "$CVSROOT/module" &&
43 cvs co -d module-cvs module &&
44 cd module-cvs &&
45 cat <<EOF >o_fortuna &&
46O Fortuna
47velut luna
48statu variabilis,
49
50semper crescis
51aut decrescis;
52vita detestabilis
53
54nunc obdurat
55et tunc curat
56ludo mentis aciem,
57
58egestatem,
59potestatem
60dissolvit ut glaciem.
61EOF
62 cvs add o_fortuna &&
63 cat <<EOF >message &&
64add "O Fortuna" lyrics
65
66These public domain lyrics make an excellent sample text.
67EOF
68 cvs commit -F message &&
69 cd ..
70'
71
72test_expect_success 'import a trivial module' '
73
74 git cvsimport -a -z 0 -C module-git module &&
75 test_cmp module-cvs/o_fortuna module-git/o_fortuna
76
77'
78
79test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
80
81test_expect_success 'update cvs module' '
82
83 cd module-cvs &&
84 cat <<EOF >o_fortuna &&
85O Fortune,
86like the moon
87you are changeable,
88
89ever waxing
90and waning;
91hateful life
92
93first oppresses
94and then soothes
95as fancy takes it;
96
97poverty
98and power
99it melts them like ice.
100EOF
101 cat <<EOF >message &&
102translate to English
103
104My Latin is terrible.
105EOF
106 cvs commit -F message &&
107 cd ..
108'
109
110test_expect_success 'update git module' '
111
112 cd module-git &&
113 git cvsimport -a -z 0 module &&
114 git merge origin &&
115 cd .. &&
116 test_cmp module-cvs/o_fortuna module-git/o_fortuna
117
118'
119
120test_expect_success 'update cvs module' '
121
122 cd module-cvs &&
123 echo 1 >tick &&
124 cvs add tick &&
125 cvs commit -m 1
126 cd ..
127
128'
129
130test_expect_success 'cvsimport.module config works' '
131
132 cd module-git &&
133 git config cvsimport.module module &&
134 git cvsimport -a -z0 &&
135 git merge origin &&
136 cd .. &&
137 test_cmp module-cvs/tick module-git/tick
138
139'
140
141test_expect_success 'import from a CVS working tree' '
142
143 cvs co -d import-from-wt module &&
144 cd import-from-wt &&
145 git cvsimport -a -z0 &&
146 echo 1 >expect &&
147 git log -1 --pretty=format:%s%n >actual &&
148 test_cmp actual expect &&
149 cd ..
150
151'
152
153test_done