1# Shell library sourced instead of ./test-lib.sh by cvsimport tests.
2
3. ./test-lib.sh
4
5unset CVS_SERVER
6
7if ! type cvs >/dev/null 2>&1
8then
9 skip_all='skipping cvsimport tests, cvs not found'
10 test_done
11fi
12
13CVS="cvs -f"
14export CVS
15
16cvsps_version=$(cvsps -h 2>&1 | sed -ne 's/cvsps version //p')
17case "$cvsps_version" in
182.1 | 2.2*)
19 ;;
20'')
21 skip_all='skipping cvsimport tests, cvsps not found'
22 test_done
23 ;;
24*)
25 skip_all='skipping cvsimport tests, unsupported cvsps version'
26 test_done
27 ;;
28esac
29
30setup_cvs_test_repository () {
31 CVSROOT="$(pwd)/.cvsroot" &&
32 cp -r "$TEST_DIRECTORY/$1/cvsroot" "$CVSROOT" &&
33 export CVSROOT
34}
35
36test_cvs_co () {
37 # Usage: test_cvs_co BRANCH_NAME
38 rm -rf module-cvs-"$1"
39 if [ "$1" = "master" ]
40 then
41 $CVS co -P -d module-cvs-"$1" -A module
42 else
43 $CVS co -P -d module-cvs-"$1" -r "$1" module
44 fi
45}
46
47test_git_co () {
48 # Usage: test_git_co BRANCH_NAME
49 (cd module-git && git checkout "$1")
50}
51
52test_cmp_branch_file () {
53 # Usage: test_cmp_branch_file BRANCH_NAME PATH
54 # The branch must already be checked out of CVS and git.
55 test_cmp module-cvs-"$1"/"$2" module-git/"$2"
56}
57
58test_cmp_branch_tree () {
59 # Usage: test_cmp_branch_tree BRANCH_NAME
60 # Check BRANCH_NAME out of CVS and git and make sure that all
61 # of the files and directories are identical.
62
63 test_cvs_co "$1" &&
64 test_git_co "$1" &&
65 (
66 cd module-cvs-"$1"
67 find . -type d -name CVS -prune -o -type f -print
68 ) | sort >module-cvs-"$1".list &&
69 (
70 cd module-git
71 find . -type d -name .git -prune -o -type f -print
72 ) | sort >module-git-"$1".list &&
73 test_cmp module-cvs-"$1".list module-git-"$1".list &&
74 cat module-cvs-"$1".list | while read f
75 do
76 test_cmp_branch_file "$1" "$f" || return 1
77 done
78}