chiark / gitweb /
autopkgtests: push test; specify dummy upload host; specify dput host and config
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Nov 2013 16:15:37 +0000 (16:15 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 Nov 2013 17:45:27 +0000 (17:45 +0000)
dgit
tests/git-template.tar [new file with mode: 0644]
tests/gnupg/pubring.gpg [new file with mode: 0644]
tests/gnupg/random_seed [new file with mode: 0644]
tests/gnupg/secring.gpg [new file with mode: 0644]
tests/gnupg/trustdb.gpg [new file with mode: 0644]
tests/lib
tests/tests/push-newpackage [new file with mode: 0755]

diff --git a/dgit b/dgit
index 38b3364829f8f200a53e33372d623de761184bc0..9b895b0350a7bc0cbf8b635b6c60779e648a1b24 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -465,6 +465,7 @@ our %defcfg = ('dgit.default.distro' => 'debian',
               'dgit-distro.test-dummy.git-path' => "$td/git",
               'dgit-distro.test-dummy.archive-query' => "dummycat:$td/aq",
               'dgit-distro.test-dummy.mirror' => "file://$td/mirror/",
+              'dgit-distro.test-dummy.upload-host' => 'test-dummy',
                );
 
 sub cfg {
diff --git a/tests/git-template.tar b/tests/git-template.tar
new file mode 100644 (file)
index 0000000..030bb8a
Binary files /dev/null and b/tests/git-template.tar differ
diff --git a/tests/gnupg/pubring.gpg b/tests/gnupg/pubring.gpg
new file mode 100644 (file)
index 0000000..bc16981
Binary files /dev/null and b/tests/gnupg/pubring.gpg differ
diff --git a/tests/gnupg/random_seed b/tests/gnupg/random_seed
new file mode 100644 (file)
index 0000000..cc75662
Binary files /dev/null and b/tests/gnupg/random_seed differ
diff --git a/tests/gnupg/secring.gpg b/tests/gnupg/secring.gpg
new file mode 100644 (file)
index 0000000..9c6519d
Binary files /dev/null and b/tests/gnupg/secring.gpg differ
diff --git a/tests/gnupg/trustdb.gpg b/tests/gnupg/trustdb.gpg
new file mode 100644 (file)
index 0000000..be4ccdd
Binary files /dev/null and b/tests/gnupg/trustdb.gpg differ
index 8823b287ba555d873f30405b84b59aee1b9eb8e8..1d2d06ade6fd4a6fa1857b2d4360822c92eb4139 100644 (file)
--- 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 (executable)
index 0000000..2d01657
--- /dev/null
@@ -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.