summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/lib b/tests/lib
new file mode 100644
index 0000000..509989a
--- /dev/null
+++ b/tests/lib
@@ -0,0 +1,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
+}