+
+t-v-tag () {
+ echo refs/tags/debian/${v//\~/_}
+}
+
+t-pushed-good () {
+ local branch=$1
+ t-ref-dsc-dgit
+ t-refs-same \
+ refs/heads/$branch \
+ `t-v-tag` \
+ 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 \
+ refs/dgit/sid \
+ `t-v-tag`
+ t-refs-notexist \
+ refs/dgit/unstable
+ )
+ git verify-tag `t-v-tag`
+}
+
+t-822-field () {
+ local file=$1
+ local field=$2
+ perl -e '
+ use Dpkg::Control::Hash;
+ my $h = new Dpkg::Control::Hash allow_pgp=>1;
+ $h->parse(\*STDIN,"'"$file"'");
+ my $val = $h->{"'$field'"},"\n";
+ die "'"$file $field"'" unless defined $val;
+ print $val,"\n";
+ ' <$file
+}
+
+t-ref-dsc-dgit () {
+ local dsc=${p}_${v}.dsc
+ local val=`t-822-field $tmp/incoming/$dsc Dgit`
+ perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
+ t-ref-same-val $dsc "$val"
+}
+
+t-apply-diff () {
+ local v1=$1
+ local v2=$2
+ (cd $troot/pkg-srcs; debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc) \
+ | patch -p1 -u
+}
+
+t-git-config () {
+ git config --global "$@"
+}
+
+t-drs () {
+ export DGIT_TEST_TROOT=$troot
+ export DGIT_TEST_TMP=$tmp
+ t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
+ t-git-config dgit-distro.test-dummy.git-check true
+ t-git-config dgit-distro.test-dummy.git-create true
+ cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
+ cp $root/tests/suites $tmp/.
+}
+
+t-dss () {
+ t-drs
+ t-git-config dgit-distro.test-dummy.ssh "$troot/dss-ssh"
+ t-git-config dgit-distro.test-dummy.git-check ssh-cmd
+ t-git-config dgit-distro.test-dummy.git-create true
+ t-git-config dgit-distro.test-dummy.git-url \
+ "ext::$troot/dss-ssh X %S /dgit/test-dummy/repos"
+
+ t-git-config dgit-distro.test-dummy.diverts.drs /drs
+ t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
+ t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
+ t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
+ t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
+
+ dss_dispatch=$tmp/dispatch-dir/distro=test-dummy
+ mkdir -p $dss_dispatch
+ ln -sf $root $dss_dispatch/dgit-live
+ ln -sf $tmp/git $dss_dispatch/repos
+ ln -sf $tmp/suites $tmp/dm.txt $dss_dispatch/
+ mkdir -p $dss_dispatch/keyrings
+ ln -sf $tmp/dd.gpg $dss_dispatch/keyrings/debian-keyring.gpg
+ ln -sf $tmp/dm.gpg $dss_dispatch/keyrings/debian-maintainers.gpg
+
+ echo 'no-such-package* drs' >$dss_dispatch/diverts
+}
+
+t-chain-test () {
+ local ct=$1
+ local d=${0%/*}
+ cd $root
+ export DGIT_TEST_TESTNAME="$testname"
+ export ADTTMP=$tmp
+ exec "$d/$ct"
+}
+
+t-alt-test () {
+ local t=${0##*/}
+ t-${t%%-*}
+ t-chain-test "${t#*-}"
+}