Skip to content

Commit b65954d

Browse files
committed
Merge branch 'hv/cvsps-tests'
* hv/cvsps-tests: t/t9600: remove exit after test_done cvsimport: extend testcase about patchset order to contain branches cvsimport: add test illustrating a bug in cvsps Add a test of "git cvsimport"'s handling of tags and branches Add some tests of git-cvsimport's handling of vendor branches Test contents of entire cvsimported "master" tree contents Use CVS's -f option if available (ignore user's ~/.cvsrc file) Start a library for cvsimport-related tests
2 parents 1c9b2d3 + 0eaadfe commit b65954d

28 files changed

+1627
-33
lines changed

t/lib-cvs.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/sh
2+
3+
. ./test-lib.sh
4+
5+
unset CVS_SERVER
6+
# for clean cvsps cache
7+
HOME=$(pwd)
8+
export HOME
9+
10+
if ! type cvs >/dev/null 2>&1
11+
then
12+
say 'skipping cvsimport tests, cvs not found'
13+
test_done
14+
fi
15+
16+
CVS="cvs -f"
17+
export CVS
18+
19+
cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
20+
case "$cvsps_version" in
21+
2.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+
;;
31+
esac
32+
33+
test_cvs_co () {
34+
# Usage: test_cvs_co BRANCH_NAME
35+
rm -rf module-cvs-"$1"
36+
if [ "$1" = "master" ]
37+
then
38+
$CVS co -P -d module-cvs-"$1" -A module
39+
else
40+
$CVS co -P -d module-cvs-"$1" -r "$1" module
41+
fi
42+
}
43+
44+
test_git_co () {
45+
# Usage: test_git_co BRANCH_NAME
46+
(cd module-git && git checkout "$1")
47+
}
48+
49+
test_cmp_branch_file () {
50+
# Usage: test_cmp_branch_file BRANCH_NAME PATH
51+
# The branch must already be checked out of CVS and git.
52+
test_cmp module-cvs-"$1"/"$2" module-git/"$2"
53+
}
54+
55+
test_cmp_branch_tree () {
56+
# Usage: test_cmp_branch_tree BRANCH_NAME
57+
# Check BRANCH_NAME out of CVS and git and make sure that all
58+
# of the files and directories are identical.
59+
60+
test_cvs_co "$1" &&
61+
test_git_co "$1" &&
62+
(
63+
cd module-cvs-"$1"
64+
find . -type d -name CVS -prune -o -type f -print
65+
) | sort >module-cvs-"$1".list &&
66+
(
67+
cd module-git
68+
find . -type d -name .git -prune -o -type f -print
69+
) | sort >module-git-"$1".list &&
70+
test_cmp module-cvs-"$1".list module-git-"$1".list &&
71+
cat module-cvs-"$1".list | while read f
72+
do
73+
test_cmp_branch_file "$1" "$f" || return 1
74+
done
75+
}

t/t9600-cvsimport.sh

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
test_description='git cvsimport basic tests'
4-
. ./test-lib.sh
4+
. ./lib-cvs.sh
55

66
if ! test_have_prereq PERL; then
77
say 'skipping git cvsimport tests, perl not available'
@@ -10,37 +10,13 @@ fi
1010

1111
CVSROOT=$(pwd)/cvsroot
1212
export CVSROOT
13-
unset CVS_SERVER
14-
# for clean cvsps cache
15-
HOME=$(pwd)
16-
export HOME
17-
18-
if ! type cvs >/dev/null 2>&1
19-
then
20-
say 'skipping cvsimport tests, cvs not found'
21-
test_done
22-
fi
23-
24-
cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
25-
case "$cvsps_version" in
26-
2.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-
;;
36-
esac
3713

38-
test_expect_success 'setup cvsroot' 'cvs init'
14+
test_expect_success 'setup cvsroot' '$CVS init'
3915

4016
test_expect_success 'setup a cvs module' '
4117
4218
mkdir "$CVSROOT/module" &&
43-
cvs co -d module-cvs module &&
19+
$CVS co -d module-cvs module &&
4420
cd module-cvs &&
4521
cat <<EOF >o_fortuna &&
4622
O Fortuna
@@ -59,13 +35,13 @@ egestatem,
5935
potestatem
6036
dissolvit ut glaciem.
6137
EOF
62-
cvs add o_fortuna &&
38+
$CVS add o_fortuna &&
6339
cat <<EOF >message &&
6440
add "O Fortuna" lyrics
6541
6642
These public domain lyrics make an excellent sample text.
6743
EOF
68-
cvs commit -F message &&
44+
$CVS commit -F message &&
6945
cd ..
7046
'
7147

@@ -103,7 +79,7 @@ translate to English
10379
10480
My Latin is terrible.
10581
EOF
106-
cvs commit -F message &&
82+
$CVS commit -F message &&
10783
cd ..
10884
'
10985

@@ -121,8 +97,8 @@ test_expect_success 'update cvs module' '
12197
12298
cd module-cvs &&
12399
echo 1 >tick &&
124-
cvs add tick &&
125-
cvs commit -m 1
100+
$CVS add tick &&
101+
$CVS commit -m 1
126102
cd ..
127103
128104
'
@@ -140,7 +116,7 @@ test_expect_success 'cvsimport.module config works' '
140116

141117
test_expect_success 'import from a CVS working tree' '
142118
143-
cvs co -d import-from-wt module &&
119+
$CVS co -d import-from-wt module &&
144120
cd import-from-wt &&
145121
git cvsimport -a -z0 &&
146122
echo 1 >expect &&
@@ -150,4 +126,6 @@ test_expect_success 'import from a CVS working tree' '
150126
151127
'
152128

129+
test_expect_success 'test entire HEAD' 'test_cmp_branch_tree master'
130+
153131
test_done

t/t9601-cvsimport-vendor-branch.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/sh
2+
3+
# Description of the files in the repository:
4+
#
5+
# imported-once.txt:
6+
#
7+
# Imported once. 1.1 and 1.1.1.1 should be identical.
8+
#
9+
# imported-twice.txt:
10+
#
11+
# Imported twice. HEAD should reflect the contents of the
12+
# second import (i.e., have the same contents as 1.1.1.2).
13+
#
14+
# imported-modified.txt:
15+
#
16+
# Imported, then modified on HEAD. HEAD should reflect the
17+
# modification.
18+
#
19+
# imported-modified-imported.txt:
20+
#
21+
# Imported, then modified on HEAD, then imported again.
22+
#
23+
# added-imported.txt,v:
24+
#
25+
# Added with 'cvs add' to create 1.1, then imported with
26+
# completely different contents to create 1.1.1.1, therefore the
27+
# vendor branch was never the default branch.
28+
#
29+
# imported-anonymously.txt:
30+
#
31+
# Like imported-twice.txt, but with a vendor branch whose branch
32+
# tag has been removed.
33+
34+
test_description='git cvsimport handling of vendor branches'
35+
. ./lib-cvs.sh
36+
37+
CVSROOT="$TEST_DIRECTORY"/t9601/cvsroot
38+
export CVSROOT
39+
40+
test_expect_success 'import a module with a vendor branch' '
41+
42+
git cvsimport -C module-git module
43+
44+
'
45+
46+
test_expect_success 'check HEAD out of cvs repository' 'test_cvs_co master'
47+
48+
test_expect_success 'check master out of git repository' 'test_git_co master'
49+
50+
test_expect_success 'check a file that was imported once' '
51+
52+
test_cmp_branch_file master imported-once.txt
53+
54+
'
55+
56+
test_expect_failure 'check a file that was imported twice' '
57+
58+
test_cmp_branch_file master imported-twice.txt
59+
60+
'
61+
62+
test_expect_success 'check a file that was imported then modified on HEAD' '
63+
64+
test_cmp_branch_file master imported-modified.txt
65+
66+
'
67+
68+
test_expect_success 'check a file that was imported, modified, then imported again' '
69+
70+
test_cmp_branch_file master imported-modified-imported.txt
71+
72+
'
73+
74+
test_expect_success 'check a file that was added to HEAD then imported' '
75+
76+
test_cmp_branch_file master added-imported.txt
77+
78+
'
79+
80+
test_expect_success 'a vendor branch whose tag has been removed' '
81+
82+
test_cmp_branch_file master imported-anonymously.txt
83+
84+
'
85+
86+
test_done

t/t9601/cvsroot/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* -whitespace

t/t9601/cvsroot/CVSROOT/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
history
2+
val-tags
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
head 1.1;
2+
access;
3+
symbols
4+
vtag-4:1.1.1.1
5+
vbranchA:1.1.1;
6+
locks; strict;
7+
comment @# @;
8+
9+
10+
1.1
11+
date 2004.02.09.15.43.15; author kfogel; state Exp;
12+
branches
13+
1.1.1.1;
14+
next ;
15+
16+
1.1.1.1
17+
date 2004.02.09.15.43.16; author kfogel; state Exp;
18+
branches;
19+
next ;
20+
21+
22+
desc
23+
@@
24+
25+
26+
1.1
27+
log
28+
@Add a file to the working copy.
29+
@
30+
text
31+
@Adding this file, before importing it with different contents.
32+
@
33+
34+
35+
1.1.1.1
36+
log
37+
@Import (vbranchA, vtag-4).
38+
@
39+
text
40+
@d1 1
41+
a1 1
42+
This is vtag-4 (on vbranchA) of added-then-imported.txt.
43+
@
44+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
head 1.1;
2+
branch 1.1.1;
3+
access;
4+
symbols
5+
vtag-1:1.1.1.1;
6+
locks; strict;
7+
comment @# @;
8+
9+
10+
1.1
11+
date 2004.02.09.15.43.13; author kfogel; state Exp;
12+
branches
13+
1.1.1.1;
14+
next ;
15+
16+
1.1.1.1
17+
date 2004.02.09.15.43.13; author kfogel; state Exp;
18+
branches;
19+
next ;
20+
21+
22+
desc
23+
@@
24+
25+
26+
1.1
27+
log
28+
@Initial revision
29+
@
30+
text
31+
@This is vtag-1 (on vbranchA) of imported-anonymously.txt.
32+
@
33+
34+
35+
1.1.1.1
36+
log
37+
@Import (vbranchA, vtag-1).
38+
@
39+
text
40+
@@
41+
42+

0 commit comments

Comments
 (0)