summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/git-template.tarbin0 -> 30720 bytes
-rw-r--r--tests/gnupg/pubring.gpgbin0 -> 1204 bytes
-rw-r--r--tests/gnupg/random_seedbin0 -> 600 bytes
-rw-r--r--tests/gnupg/secring.gpgbin0 -> 2506 bytes
-rw-r--r--tests/gnupg/trustdb.gpgbin0 -> 1280 bytes
-rw-r--r--tests/lib81
-rwxr-xr-xtests/tests/push-newpackage24
7 files changed, 98 insertions, 7 deletions
diff --git a/tests/git-template.tar b/tests/git-template.tar
new file mode 100644
index 0000000..030bb8a
--- /dev/null
+++ b/tests/git-template.tar
Binary files differ
diff --git a/tests/gnupg/pubring.gpg b/tests/gnupg/pubring.gpg
new file mode 100644
index 0000000..bc16981
--- /dev/null
+++ b/tests/gnupg/pubring.gpg
Binary files differ
diff --git a/tests/gnupg/random_seed b/tests/gnupg/random_seed
new file mode 100644
index 0000000..cc75662
--- /dev/null
+++ b/tests/gnupg/random_seed
Binary files differ
diff --git a/tests/gnupg/secring.gpg b/tests/gnupg/secring.gpg
new file mode 100644
index 0000000..9c6519d
--- /dev/null
+++ b/tests/gnupg/secring.gpg
Binary files differ
diff --git a/tests/gnupg/trustdb.gpg b/tests/gnupg/trustdb.gpg
new file mode 100644
index 0000000..be4ccdd
--- /dev/null
+++ b/tests/gnupg/trustdb.gpg
Binary files differ
diff --git a/tests/lib b/tests/lib
index 8823b28..1d2d06a 100644
--- a/tests/lib
+++ b/tests/lib
@@ -20,8 +20,18 @@ export DGIT_TEST_DUMMY_DIR=$tmp
ln $troot/ssh ssh
mkdir $tmp/gnupg
+cp $troot/gnupg/* $tmp/gnupg
+chmod go-rw $tmp/gnupg/*
export GNUPGHOME=$tmp/gnupg
+mkdir $tmp/incoming
+cat <<END >$tmp/dput.cf
+[test-dummy]
+method = local
+incoming = $tmp/incoming
+run_dinstall = 0
+END
+
t-worktree () {
rm -rf $p
tar xf $troot/worktrees/${p}_$1.tar
@@ -29,6 +39,7 @@ t-worktree () {
t-git-none () {
mkdir -p $tmp/git
+ (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
}
t-has-ancestor () {
@@ -41,14 +52,18 @@ t-has-ancestor () {
fi
}
-t-archive () {
+t-archive-none () {
p=$1
- v=$2
mkdir -p $tmp/aq $tmp/mirror
+ echo sid >$tmp/aq/suite.unstable
+}
+
+t-archive () {
+ t-archive-none $1
+ v=$2
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
@@ -57,7 +72,8 @@ t-archive () {
t-dgit () {
: '{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
- ${DGIT_TEST-dgit} --dget:-u -dtest-dummy -D "$@"
+ ${DGIT_TEST-dgit} --dget:-u --dput:--config=$tmp/dput.cf \
+ -dtest-dummy -D -k39B13D8A "$@"
: '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}'
}
@@ -68,7 +84,10 @@ t-diff-nogit () {
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-refs-same \
+ refs/heads/dgit/sid \
+ refs/remotes/dgit/dgit/sid
+ t-refs-notexist dgit/unstable remotes/dgit/dgit/unstable
}
t-output () {
@@ -82,12 +101,60 @@ t-clean-on-branch () {
t-output "## $1" git status -b --porcelain
}
+t-git-get-ref () {
+ local ref=$1
+ git-show-ref -d $1 | perl -ne '
+ $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
+ END { print "$x\n" if length $x; }
+ '
+}
+
t-refs-same () {
local f=$1
- git rev-parse $f >$tmp/t.ref1
+ t-git-get-ref $f >$tmp/t.ref1
+ t-refs-same-more "$@"
+}
+
+t-refs-same-more () {
local g
for g in $*; do
- git rev-parse $g >$tmp/t.refn
+ t-git-get-ref $g >$tmp/t.refn
diff $tmp/t.ref1 $tmp/t.refn
done
}
+
+t-refs-notexist () {
+ for g in $*; do
+ t-git-get-ref $g >$tmp/t.refx
+ diff /dev/null $tmp/t.refx
+ done
+}
+
+t-pushed-good () {
+ t-ref-dsc-dgit
+ t-refs-same-more \
+ refs/heads/master \
+ refs/tags/debian/$v \
+ refs/remotes/dgit/dgit/sid
+ t-refs-notexist \
+ refs/heads/dgit/unstable \
+ refs/remotes/dgit/dgit/unstable
+ (set -e; cd $tmp/git/$p.git
+ t-refs-same-more \
+ refs/dgit/sid \
+ refs/tags/debian/$v
+ t-refs-notexist \
+ refs/dgit/unstable
+ )
+}
+
+t-ref-dsc-dgit () {
+ perl -e '
+ use Dpkg::Control::Hash;
+ my $h = new Dpkg::Control::Hash allow_pgp=>1;
+ $h->parse(\*STDIN,"dsc");
+ my $ref = $h->{"Dgit"},"\n";
+ die unless $ref =~ m/^\w+\b/;
+ print $ref,"\n";
+ ' <$tmp/incoming/${p}_${v}.dsc >$tmp/t.ref1
+}
diff --git a/tests/tests/push-newpackage b/tests/tests/push-newpackage
new file mode 100755
index 0000000..2d01657
--- /dev/null
+++ b/tests/tests/push-newpackage
@@ -0,0 +1,24 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-archive-none pari-extra
+t-git-none
+t-worktree 3-1
+v=3-1
+cd $p
+git-branch -m dgit/sid master
+git-remote rm dgit
+
+LANG=C t-dgit push 2>&1 \
+ | tee /dev/stderr \
+ | grep 'package appears to be new in this suite' >/dev/null
+
+echo y
+
+t-dgit build
+t-dgit push --new
+
+t-pushed-good
+
+echo ok.