cvsimport: extend testcase about patchset order to contain branches
[git] / t / lib-cvs.sh
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         exit
15 fi
16
17 CVS="cvs -f"
18 export CVS
19
20 cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
21 case "$cvsps_version" in
22 2.1 | 2.2*)
23         ;;
24 '')
25         say 'skipping cvsimport tests, cvsps not found'
26         test_done
27         exit
28         ;;
29 *)
30         say 'skipping cvsimport tests, unsupported cvsps version'
31         test_done
32         exit
33         ;;
34 esac
35
36 test_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
47 test_git_co () {
48         # Usage: test_git_co BRANCH_NAME
49         (cd module-git && git checkout "$1")
50 }
51
52 test_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
58 test_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 }