summaryrefslogtreecommitdiff
path: root/tests/lib
blob: 509989a1733d31ad1be7e6097dca473adda44e42 (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
#

exec 2>&1

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

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

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

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

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

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
}