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