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