10 : ${DGIT_TEST_DEBUG:=-D}
11 export DGIT_TEST_DEBUG
15 testname="${DGIT_TEST_TESTNAME-${0##*/}}"
18 if [ x"$tmp" = x ]; then
20 tmp=tests/tmp/$testname
28 export DGIT_TEST_DUMMY_DIR=$tmp
32 cp $troot/gnupg/* $tmp/gnupg
33 chmod go-rw $tmp/gnupg/*
34 export GNUPGHOME=$tmp/gnupg
36 mkdir -p $tmp/incoming
37 cat <<END >$tmp/dput.cf
40 incoming = $tmp/incoming
45 local mpat="$1"; shift
46 LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
47 test ${PIPESTATUS[0]} != 0
48 egrep "$mpat" $tmp/t.output ||false
53 local edittree=$1.edit
54 if test -d "$edittree"; then
55 cp -al "$edittree"/* .
63 t-untar $troot/worktrees/${p}_$1
70 local gs=$troot/git-srcs/${p}_$v.git
71 (set -e; cd $tmp/git; t-untar $gs)
76 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
80 local now=`git rev-parse HEAD`
81 local ancestor=`git rev-parse $1^{}`
82 local mbase=`git merge-base $ancestor $now`
83 if [ x$mbase != x$ancestor ]; then
84 fail "not ff $ancestor..$now, $mbase != $ancestor"
88 t-prep-newpackage () {
96 git branch -m dgit/sid master
103 mkdir -p $tmp/aq $tmp/mirror/pool/main
107 >$tmp/aq/package.$suite.$p
108 t-archive-updated $suite $p
110 >$tmp/aq/package.new.$p
111 t-archive-updated new $p
113 ln -s sid $tmp/aq/dsc_in_suite/unstable
114 cat <<'END' >$tmp/aq/suites
117 "archive" : "ftp-master",
125 "dakname" : "unstable"
131 t-archive-updated () {
134 local suitedir=$tmp/aq/dsc_in_suite/$suite
136 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
140 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
148 print to_json \@v or die $!;
153 t-archive-process-incoming () {
154 mv incoming/${p}_${v}[._]* mirror/pool/main/
159 local dscf=main/${p}_${v}.dsc
160 local sha=`sha256sum <mirror/pool/$dscf`
161 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.sid.${p}
162 t-archive-updated sid $p
168 local dscf=${p}_$2.dsc
169 rm -f $tmp/mirror/pool/main/${p}_*
170 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
174 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
178 local dgit=${DGIT_TEST-dgit}
180 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
181 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
182 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
184 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
189 diff --exclude=.git --exclude=.pc -ruN $*
192 t-cloned-fetched-good () {
193 t-diff-nogit ../extract/$p-${v%-*} .
194 t-clean-on-branch dgit/sid
197 refs/heads/dgit/sid \
198 refs/remotes/dgit/dgit/sid
199 t-refs-notexist dgit/unstable remotes/dgit/dgit/unstable
203 printf "%s\n" "$1" >$tmp/t.want
206 diff $tmp/t.want $tmp/t.got
209 t-clean-on-branch () {
210 t-output "## $1" git status -b --porcelain
215 git show-ref -d $1 | perl -ne '
216 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
217 END { print "$x\n" if length $x; }
223 local val=`t-git-get-ref $name`
224 t-ref-same-val "$name" $val
228 local val=`git rev-parse HEAD`
229 t-ref-same-val HEAD $val
238 *) fail "ref varies: $name: $val != $t_ref_val" ;;
243 t-refs-same-start () {
257 val=`t-git-get-ref $g >$tmp/t.refx`
258 if [ "x$val" != x ]; then
259 fail "ref $g unexpectedly exists ($val)"
265 echo refs/tags/debian/${v//\~/_}
274 refs/remotes/dgit/dgit/sid
276 refs/heads/dgit/unstable \
277 refs/remotes/dgit/dgit/unstable
278 (set -e; cd $tmp/git/$p.git
285 git verify-tag `t-v-tag`
292 use Dpkg::Control::Hash;
293 my $h = new Dpkg::Control::Hash allow_pgp=>1;
294 $h->parse(\*STDIN,"'"$file"'");
295 my $val = $h->{"'$field'"},"\n";
296 die "'"$file $field"'" unless defined $val;
302 local dsc=${p}_${v}.dsc
303 local val=`t-822-field $tmp/incoming/$dsc Dgit`
304 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
305 t-ref-same-val $dsc "$val"
311 (cd $troot/pkg-srcs; debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc) \
316 git config --global "$@"
320 export DGIT_TEST_TROOT=$troot
321 export DGIT_TEST_TMP=$tmp
322 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
323 t-git-config dgit-distro.test-dummy.git-check true
324 t-git-config dgit-distro.test-dummy.git-create true
325 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
326 cp $root/tests/suites $tmp/.
328 drs_dispatch=$tmp/distro=test-dummy
330 ln -sf $root $drs_dispatch/dgit-live
331 ln -sf $tmp/git $drs_dispatch/repos
332 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
333 mkdir -p $drs_dispatch/keyrings
334 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
335 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
336 ln -sf /bin/true $drs_dispatch/policy-hook
341 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
342 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
343 t-git-config dgit-distro.test-dummy.git-create true
344 t-git-config dgit-distro.test-dummy.git-url \
345 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
347 t-git-config dgit-distro.test-dummy.diverts.drs /drs
348 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
349 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
350 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
351 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
353 echo 'no-such-package* drs' >$drs_dispatch/diverts
357 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
363 ln -sf ${DGIT_INFRA_PFX}dgit-repos-policy-debian \
364 $drs_dispatch/policy-hook
367 t-policy-admin create-db
374 export DGIT_TEST_TESTNAME="$testname"
382 t-chain-test "${t#*-}"