summaryrefslogtreecommitdiff
path: root/tests/lib
blob: 5ce17d6c56c36c22137d97ebdfc1413efbbb958f (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
79
80
81
82
83
#

exec 2>&1
set -x

root=`pwd`
troot=$root/tests
testname="${0##*/}"

tmp=$ADTTMP
if [ x"$tmp" = x ]; then
	mkdir -p tests/tmp
	tmp=tests/tmp/$testname
	rm -rf $tmp
	mkdir $tmp
fi
cd $tmp
tmp=`pwd`
export DGIT_TEST_DUMMY_DIR=$tmp
ln $troot/ssh ssh

mkdir $tmp/gnupg
export GNUPGHOME=$tmp/gnupg

t-git () {
	mkdir -p $tmp/git
	cp -al $troot/git-srcs/$1 git/.
}

t-git-none () {
	mkdir -p $tmp/git
}

t-archive () {
	p=$1
	v=$2
	mkdir -p $tmp/aq $tmp/mirror
	local dscf=${p}_$2.dsc
	rm -f $tmp/mirror/${p}_*
	ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/
	echo sid >$tmp/aq/suite.unstable
	echo "$2 $dscf" >>$tmp/aq/package.sid.${p}
	rm -rf $tmp/extract
	mkdir $tmp/extract
	(set -e; cd $tmp/extract; dpkg-source -x ../mirror/$dscf)
}

t-dgit () {
	: '{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
	${DGIT_TEST-dgit} --dget:-u -dtest-dummy -D "$@"
	: '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}'
}

t-diff-nogit () {
	diff --exclude=.git -ruN $*
}

t-cloned-fetched-good () {
	t-diff-nogit ../extract/$p-${v%-*} .
	t-clean-on-branch dgit/sid
	t-refs-same HEAD remotes/dgit/dgit/sid
}

t-output () {
	printf "%s\n" "$1" >$tmp/t.want
	shift
	"$@" >$tmp/t.got
	diff $tmp/t.want $tmp/t.got
}

t-clean-on-branch () {
	t-output "## $1" git status -b --porcelain
}

t-refs-same () {
	local f=$1
	git rev-parse $f >$tmp/t.ref1
	local g
	for g in $*; do
		git rev-parse $g >$tmp/t.refn
		diff $tmp/t.ref1 $tmp/t.refn
	done
}