Skip to content

Commit

Permalink
Merge branch 'hv/cvsps-tests'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Jul 29, 2009
2 parents 1c9b2d3 + 0eaadfe commit b65954d
Show file tree
Hide file tree
Showing 28 changed files with 1,627 additions and 33 deletions.
75 changes: 75 additions & 0 deletions t/lib-cvs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/sh

. ./test-lib.sh

unset CVS_SERVER
# for clean cvsps cache
HOME=$(pwd)
export HOME

if ! type cvs >/dev/null 2>&1
then
say 'skipping cvsimport tests, cvs not found'
test_done
fi

CVS="cvs -f"
export CVS

cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
case "$cvsps_version" in
2.1 | 2.2*)
;;
'')
say 'skipping cvsimport tests, cvsps not found'
test_done
;;
*)
say 'skipping cvsimport tests, unsupported cvsps version'
test_done
;;
esac

test_cvs_co () {
# Usage: test_cvs_co BRANCH_NAME
rm -rf module-cvs-"$1"
if [ "$1" = "master" ]
then
$CVS co -P -d module-cvs-"$1" -A module
else
$CVS co -P -d module-cvs-"$1" -r "$1" module
fi
}

test_git_co () {
# Usage: test_git_co BRANCH_NAME
(cd module-git && git checkout "$1")
}

test_cmp_branch_file () {
# Usage: test_cmp_branch_file BRANCH_NAME PATH
# The branch must already be checked out of CVS and git.
test_cmp module-cvs-"$1"/"$2" module-git/"$2"
}

test_cmp_branch_tree () {
# Usage: test_cmp_branch_tree BRANCH_NAME
# Check BRANCH_NAME out of CVS and git and make sure that all
# of the files and directories are identical.

test_cvs_co "$1" &&
test_git_co "$1" &&
(
cd module-cvs-"$1"
find . -type d -name CVS -prune -o -type f -print
) | sort >module-cvs-"$1".list &&
(
cd module-git
find . -type d -name .git -prune -o -type f -print
) | sort >module-git-"$1".list &&
test_cmp module-cvs-"$1".list module-git-"$1".list &&
cat module-cvs-"$1".list | while read f
do
test_cmp_branch_file "$1" "$f" || return 1
done
}
44 changes: 11 additions & 33 deletions t/t9600-cvsimport.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

test_description='git cvsimport basic tests'
. ./test-lib.sh
. ./lib-cvs.sh

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

CVSROOT=$(pwd)/cvsroot
export CVSROOT
unset CVS_SERVER
# for clean cvsps cache
HOME=$(pwd)
export HOME

if ! type cvs >/dev/null 2>&1
then
say 'skipping cvsimport tests, cvs not found'
test_done
fi

cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
case "$cvsps_version" in
2.1 | 2.2*)
;;
'')
say 'skipping cvsimport tests, cvsps not found'
test_done
;;
*)
say 'skipping cvsimport tests, unsupported cvsps version'
test_done
;;
esac

test_expect_success 'setup cvsroot' 'cvs init'
test_expect_success 'setup cvsroot' '$CVS init'

test_expect_success 'setup a cvs module' '
mkdir "$CVSROOT/module" &&
cvs co -d module-cvs module &&
$CVS co -d module-cvs module &&
cd module-cvs &&
cat <<EOF >o_fortuna &&
O Fortuna
Expand All @@ -59,13 +35,13 @@ egestatem,
potestatem
dissolvit ut glaciem.
EOF
cvs add o_fortuna &&
$CVS add o_fortuna &&
cat <<EOF >message &&
add "O Fortuna" lyrics
These public domain lyrics make an excellent sample text.
EOF
cvs commit -F message &&
$CVS commit -F message &&
cd ..
'

Expand Down Expand Up @@ -103,7 +79,7 @@ translate to English
My Latin is terrible.
EOF
cvs commit -F message &&
$CVS commit -F message &&
cd ..
'

Expand All @@ -121,8 +97,8 @@ test_expect_success 'update cvs module' '
cd module-cvs &&
echo 1 >tick &&
cvs add tick &&
cvs commit -m 1
$CVS add tick &&
$CVS commit -m 1
cd ..
'
Expand All @@ -140,7 +116,7 @@ test_expect_success 'cvsimport.module config works' '

test_expect_success 'import from a CVS working tree' '
cvs co -d import-from-wt module &&
$CVS co -d import-from-wt module &&
cd import-from-wt &&
git cvsimport -a -z0 &&
echo 1 >expect &&
Expand All @@ -150,4 +126,6 @@ test_expect_success 'import from a CVS working tree' '
'

test_expect_success 'test entire HEAD' 'test_cmp_branch_tree master'

test_done
86 changes: 86 additions & 0 deletions t/t9601-cvsimport-vendor-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh

# Description of the files in the repository:
#
# imported-once.txt:
#
# Imported once. 1.1 and 1.1.1.1 should be identical.
#
# imported-twice.txt:
#
# Imported twice. HEAD should reflect the contents of the
# second import (i.e., have the same contents as 1.1.1.2).
#
# imported-modified.txt:
#
# Imported, then modified on HEAD. HEAD should reflect the
# modification.
#
# imported-modified-imported.txt:
#
# Imported, then modified on HEAD, then imported again.
#
# added-imported.txt,v:
#
# Added with 'cvs add' to create 1.1, then imported with
# completely different contents to create 1.1.1.1, therefore the
# vendor branch was never the default branch.
#
# imported-anonymously.txt:
#
# Like imported-twice.txt, but with a vendor branch whose branch
# tag has been removed.

test_description='git cvsimport handling of vendor branches'
. ./lib-cvs.sh

CVSROOT="$TEST_DIRECTORY"/t9601/cvsroot
export CVSROOT

test_expect_success 'import a module with a vendor branch' '
git cvsimport -C module-git module
'

test_expect_success 'check HEAD out of cvs repository' 'test_cvs_co master'

test_expect_success 'check master out of git repository' 'test_git_co master'

test_expect_success 'check a file that was imported once' '
test_cmp_branch_file master imported-once.txt
'

test_expect_failure 'check a file that was imported twice' '
test_cmp_branch_file master imported-twice.txt
'

test_expect_success 'check a file that was imported then modified on HEAD' '
test_cmp_branch_file master imported-modified.txt
'

test_expect_success 'check a file that was imported, modified, then imported again' '
test_cmp_branch_file master imported-modified-imported.txt
'

test_expect_success 'check a file that was added to HEAD then imported' '
test_cmp_branch_file master added-imported.txt
'

test_expect_success 'a vendor branch whose tag has been removed' '
test_cmp_branch_file master imported-anonymously.txt
'

test_done
1 change: 1 addition & 0 deletions t/t9601/cvsroot/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -whitespace
2 changes: 2 additions & 0 deletions t/t9601/cvsroot/CVSROOT/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
history
val-tags
44 changes: 44 additions & 0 deletions t/t9601/cvsroot/module/added-imported.txt,v
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
head 1.1;
access;
symbols
vtag-4:1.1.1.1
vbranchA:1.1.1;
locks; strict;
comment @# @;


1.1
date 2004.02.09.15.43.15; author kfogel; state Exp;
branches
1.1.1.1;
next ;

1.1.1.1
date 2004.02.09.15.43.16; author kfogel; state Exp;
branches;
next ;


desc
@@


1.1
log
@Add a file to the working copy.
@
text
@Adding this file, before importing it with different contents.
@


1.1.1.1
log
@Import (vbranchA, vtag-4).
@
text
@d1 1
a1 1
This is vtag-4 (on vbranchA) of added-then-imported.txt.
@

42 changes: 42 additions & 0 deletions t/t9601/cvsroot/module/imported-anonymously.txt,v
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
head 1.1;
branch 1.1.1;
access;
symbols
vtag-1:1.1.1.1;
locks; strict;
comment @# @;


1.1
date 2004.02.09.15.43.13; author kfogel; state Exp;
branches
1.1.1.1;
next ;

1.1.1.1
date 2004.02.09.15.43.13; author kfogel; state Exp;
branches;
next ;


desc
@@


1.1
log
@Initial revision
@
text
@This is vtag-1 (on vbranchA) of imported-anonymously.txt.
@


1.1.1.1
log
@Import (vbranchA, vtag-1).
@
text
@@


Loading

0 comments on commit b65954d

Please sign in to comment.