11 : ${DGIT_TEST_DEBUG:=-D}
12 export DGIT_TEST_DEBUG
16 testname="${DGIT_TEST_TESTNAME-${0##*/}}"
19 if [ x"$tmp" = x ]; then
21 tmp=tests/tmp/$testname
34 cp $troot/gnupg/* $tmp/gnupg
35 chmod go-rw $tmp/gnupg/*
37 mkdir -p $tmp/incoming
38 cat <<END >$tmp/dput.cf
41 incoming = $tmp/incoming
46 local mpat="$1"; shift
54 *) fail "bad mpat prefix in $mpat";;
61 LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
62 local ps="${PIPESTATUS[*]}"
66 "0 0") fail "command unexpectedly succeeded (instead of: $mpat)" ;;
68 *) fail "tee failed" ;;
71 $grepper -e "$mpat" $tmp/t.output ||
72 fail "error message not found"
75 t-expect-push-fail () {
76 local mpat="$1"; shift
78 t-expect-fail "$mpat" "$@"
80 diff $tmp/show-refs.{pre,post}-push
84 local whichoutput=$1; shift
85 local outputfile="$tmp/show-refs.$whichoutput"
88 if test -d $tmp/git/$p.git; then
96 local edittree=$1.edit
97 if test -d "$edittree"; then
98 cp -al "$edittree"/* .
106 t-untar $troot/worktrees/${p}_$1
113 local gs=$troot/git-srcs/${p}_$v.git
114 (set -e; cd $tmp/git; t-untar $gs)
119 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
123 local now=`git rev-parse HEAD`
124 local ancestor=`git rev-parse $1^{}`
125 local mbase=`git merge-base $ancestor $now`
126 if [ x$mbase != x$ancestor ]; then
127 fail "not ff $ancestor..$now, $mbase != $ancestor"
131 t-prep-newpackage () {
138 if ! git-show-ref --verify --quiet refs/heads/master; then
139 git branch -m dgit/sid master
147 mkdir -p $tmp/aq $tmp/mirror/pool/main
151 >$tmp/aq/package.$suite.$p
152 t-archive-updated $suite $p
154 >$tmp/aq/package.new.$p
155 t-archive-updated new $p
157 ln -s sid $tmp/aq/dsc_in_suite/unstable
158 cat <<'END' >$tmp/aq/suites
161 "archive" : "ftp-master",
169 "dakname" : "unstable"
175 t-archive-updated () {
178 local suitedir=$tmp/aq/dsc_in_suite/$suite
180 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
184 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
192 print to_json \@v or die $!;
197 t-archive-process-incoming () {
199 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
200 t-archive-query "$suite"
205 local dscf=main/${p}_${v}.dsc
206 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
207 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
208 t-archive-updated $suite $p
214 local dscf=${p}_$2.dsc
215 rm -f $tmp/mirror/pool/main/${p}_*
216 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
220 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
223 t-git-dir-time-passes () {
224 touch -d 'last year' $tmp/git/$p.git
228 local gitdir=$tmp/git/$p.git
231 if test -e "$gitdir"; then fail "$gitdir exists"; fi
234 public) wantstat='7[75]5' ;;
235 secret) wantstat='7[70]0' ;;
236 *) fail "$1 t-git-dir-check ?" ;;
238 gotstat=`stat -c%a $gitdir`
240 *$wantstat) return ;;
241 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
245 t-rm-dput-dropping () {
246 rm -f $tmp/${p}_${v}_*.upload
250 local dgit=${DGIT_TEST-dgit}
252 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
253 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
254 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
256 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
261 diff --exclude=.git --exclude=.pc -ruN $*
264 t-cloned-fetched-good () {
265 t-diff-nogit ../extract/$p-${v%-*} .
266 t-clean-on-branch dgit/sid
269 refs/heads/dgit/sid \
270 refs/remotes/dgit/dgit/sid
271 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
275 printf "%s\n" "$1" >$tmp/t.want
278 diff $tmp/t.want $tmp/t.got
281 t-clean-on-branch () {
282 t-output "## $1" git status -b --porcelain
289 *) fail "t-git-get-ref bad $ref" ;;
291 (git show-ref -d $1 || test $? = 1) | perl -ne '
292 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
293 END { print "$x\n" if length $x; }
299 local val=`t-git-get-ref $name`
300 t-ref-same-val "$name" $val
304 local val=`git rev-parse HEAD`
305 t-ref-same-val HEAD $val
314 *) fail "ref varies: $name: $val != $t_ref_val" ;;
319 t-refs-same-start () {
333 val=`t-git-get-ref $g >$tmp/t.refx`
334 if [ "x$val" != x ]; then
335 fail "ref $g unexpectedly exists ($val)"
341 echo refs/tags/debian/${v//\~/_}
350 refs/remotes/dgit/dgit/sid
352 refs/heads/dgit/unstable \
353 refs/remotes/dgit/dgit/unstable
354 (set -e; cd $tmp/git/$p.git
361 git verify-tag `t-v-tag`
368 use Dpkg::Control::Hash;
369 my $h = new Dpkg::Control::Hash allow_pgp=>1;
370 $h->parse(\*STDIN,"'"$file"'");
371 my $val = $h->{"'$field'"},"\n";
372 die "'"$file $field"'" unless defined $val;
384 *) '$var'="$tstunt:$'$var'" ;;
390 local tstunt=$tmp/tstunt
391 t-stunt-envvar PATH $tstunt
392 t-stunt-envvar PERLLIB $tstunt
396 local d="$tstunt/${f%/*}"
398 ln -sf "$troot/tstunt/$f" "$d"/.
402 t-tstunt-parsechangelog () {
403 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
407 local dsc=${p}_${v}.dsc
408 local val=`t-822-field $tmp/incoming/$dsc Dgit`
409 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
410 t-ref-same-val $dsc "$val"
417 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
424 dch -v$v --distribution unstable "$1"
425 git add debian/changelog
427 revision=$(( $revision + 1 ))
431 git config --global "$@"
435 export DGIT_TEST_TROOT=$troot
436 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
437 t-git-config dgit-distro.test-dummy.git-check true
438 t-git-config dgit-distro.test-dummy.git-create true
439 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
440 cp $root/tests/suites $tmp/.
442 drs_dispatch=$tmp/distro=test-dummy
444 ln -sf $root $drs_dispatch/dgit-live
445 ln -sf $tmp/git $drs_dispatch/repos
446 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
447 mkdir -p $drs_dispatch/keyrings
448 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
449 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
450 ln -sf /bin/true $drs_dispatch/policy-hook
455 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
456 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
457 t-git-config dgit-distro.test-dummy.git-create true
458 t-git-config dgit-distro.test-dummy.git-url \
459 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
461 t-git-config dgit-distro.test-dummy.diverts.drs /drs
462 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
463 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
464 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
465 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
467 echo 'no-such-package* drs' >$drs_dispatch/diverts
471 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
476 ln -sf ${DGIT_INFRA_PFX}$policyhook \
477 $drs_dispatch/policy-hook
482 t-policy dgit-repos-policy-debian
485 t-policy-admin create-db
488 t-policy-periodic () {
489 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
490 test-dummy $drs_dispatch '' --cron
497 export DGIT_TEST_TESTNAME="$testname"
505 t-chain-test "${t#*-}"