summaryrefslogtreecommitdiff
path: root/t/lib-cvs.sh
blob: 1f73c07df8573aa356fbc17109bc44a387455343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/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
	exit
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
	exit
	;;
*)
	say 'skipping cvsimport tests, unsupported cvsps version'
	test_done
	exit
	;;
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
}