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 export DEBCHANGE_VENDOR=dpkg
39 mkdir -p $tmp/incoming
40 cat <<END >$tmp/dput.cf
43 incoming = $tmp/incoming
48 local mpat="$1"; shift
56 *) fail "bad mpat prefix in $mpat";;
63 LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
64 local ps="${PIPESTATUS[*]}"
68 "0 0") fail "command unexpectedly succeeded (instead of: $mpat)" ;;
70 *) fail "tee failed" ;;
73 $grepper -e "$mpat" $tmp/t.output ||
74 fail "error message not found"
77 t-expect-push-fail () {
78 local mpat="$1"; shift
80 local triedpush=`git rev-parse HEAD`
83 t-expect-fail "$mpat" "$@"
85 diff $tmp/show-refs.{pre,post}-push
87 t-git-objects-not-present '' $triedpush
89 eval "$t_expect_push_fail_hook"
92 t-git-objects-not-present () {
93 # t-git-objects-not-present GITDIR|'' OBJID [...]
94 # specifying '' means the repo for package $p
95 local gitdir="${1-$tmp/git/$p.git}"
97 if ! [ -e "$gitdir" ]; then return; fi
100 t-expect-fail 'unable to find' \
106 local whichoutput=$1; shift
107 local outputfile="$tmp/show-refs.$whichoutput"
110 if test -d $tmp/git/$p.git; then
118 local edittree=$1.edit
119 if test -d "$edittree"; then
120 cp -al "$edittree"/* .
128 t-untar $troot/worktrees/${p}_$1
135 local gs=$troot/git-srcs/${p}_$v.git
136 (set -e; cd $tmp/git; t-untar $gs)
141 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
145 local now=`git rev-parse HEAD`
146 local ancestor=`git rev-parse $1^{}`
147 local mbase=`git merge-base $ancestor $now`
148 if [ x$mbase != x$ancestor ]; then
149 fail "not ff $ancestor..$now, $mbase != $ancestor"
153 t-prep-newpackage () {
160 if ! git show-ref --verify --quiet refs/heads/master; then
161 git branch -m dgit/sid master
169 mkdir -p $tmp/aq $tmp/mirror/pool/main
173 >$tmp/aq/package.$suite.$p
174 t-archive-updated $suite $p
176 >$tmp/aq/package.new.$p
177 t-archive-updated new $p
179 ln -s sid $tmp/aq/dsc_in_suite/unstable
180 cat <<'END' >$tmp/aq/suites
183 "archive" : "ftp-master",
191 "dakname" : "unstable"
197 t-archive-updated () {
200 local suitedir=$tmp/aq/dsc_in_suite/$suite
202 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
206 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
214 print to_json \@v or die $!;
219 t-archive-process-incoming () {
221 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
222 t-archive-query "$suite"
227 local dscf=main/${p}_${v}.dsc
228 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
229 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
230 t-archive-updated $suite $p
236 local dscf=${p}_$2.dsc
237 rm -f $tmp/mirror/pool/main/${p}_*
238 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
242 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
245 t-git-dir-time-passes () {
246 touch -d 'last year' $tmp/git/$p.git
250 local gitdir=$tmp/git/$p.git
253 if test -e "$gitdir"; then fail "$gitdir exists"; fi
256 public) wantstat='7[75]5' ;;
257 secret) wantstat='7[70]0' ;;
258 *) fail "$1 t-git-dir-check ?" ;;
260 gotstat=`stat -c%a $gitdir`
262 *$wantstat) return ;;
263 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
267 t-rm-dput-dropping () {
268 rm -f $tmp/${p}_${v}_*.upload
272 local dgit=${DGIT_TEST-dgit}
274 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
275 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
276 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
278 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
283 diff --exclude=.git --exclude=.pc -ruN $*
286 t-cloned-fetched-good () {
287 t-diff-nogit ../extract/$p-${v%-*} .
288 t-clean-on-branch dgit/sid
291 refs/heads/dgit/sid \
292 refs/remotes/dgit/dgit/sid
293 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
297 printf "%s\n" "$1" >$tmp/t.want
300 diff $tmp/t.want $tmp/t.got
303 t-clean-on-branch () {
304 t-output "## $1" git status -b --porcelain
307 t-git-get-ref-exact () {
309 # does not dereference, unlike t-git-get-ref
312 *) fail "t-git-get-ref-exact bad $ref" ;;
314 git for-each-ref --format='%(objectname)' "[r]efs/${ref#refs/}"
321 *) fail "t-git-get-ref bad $ref" ;;
323 (git show-ref -d $1 || test $? = 1) | perl -ne '
324 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
325 END { print "$x\n" if length $x; }
331 local val=`t-git-get-ref $name`
332 t-ref-same-val "$name" $val
336 local val=`git rev-parse HEAD`
337 t-ref-same-val HEAD $val
346 *) fail "ref varies: $name: $val != $t_ref_val" ;;
351 t-refs-same-start () {
365 val=`t-git-get-ref $g >$tmp/t.refx`
366 if [ "x$val" != x ]; then
367 fail "ref $g unexpectedly exists ($val)"
373 echo refs/tags/debian/${v//\~/_}
382 refs/remotes/dgit/dgit/sid
384 refs/heads/dgit/unstable \
385 refs/remotes/dgit/dgit/unstable
386 (set -e; cd $tmp/git/$p.git
393 git verify-tag `t-v-tag`
400 use Dpkg::Control::Hash;
401 my $h = new Dpkg::Control::Hash allow_pgp=>1;
402 $h->parse(\*STDIN,"'"$file"'");
403 my $val = $h->{"'$field'"},"\n";
404 die "'"$file $field"'" unless defined $val;
416 *) '$var'="$tstunt:$'$var'" ;;
422 local tstunt=$tmp/tstunt
423 t-stunt-envvar PATH $tstunt
424 t-stunt-envvar PERLLIB $tstunt
428 local d="$tstunt/${f%/*}"
430 ln -sf "$troot/tstunt/$f" "$d"/.
434 t-tstunt-parsechangelog () {
435 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
438 t-prep-mergechangelogs () {
439 local b=merge.dpkg-mergechangelogs
440 git config $b.name 'debian/changelog merge driver'
441 git config $b.driver 'dpkg-mergechangelogs -m %O %A %B %A'
443 echo >>.git/info/attributes \
444 'debian/changelog merge=dpkg-mergechangelogs'
448 local dsc=${p}_${v}.dsc
449 local val=`t-822-field $tmp/incoming/$dsc Dgit`
450 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
451 t-ref-same-val $dsc "$val"
458 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
465 dch -v$v --distribution unstable "$1"
466 git add debian/changelog
468 revision=$(( $revision + 1 ))
472 git config --global "$@"
476 export DGIT_TEST_TROOT=$troot
477 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
478 t-git-config dgit-distro.test-dummy.git-check true
479 t-git-config dgit-distro.test-dummy.git-create true
480 cp $troot/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
481 cp $troot/suites $tmp/.
483 drs_dispatch=$tmp/distro=test-dummy
486 if [ "x$DGIT_TEST_INTREE" != x ]; then
487 ln -sf "$DGIT_TEST_INTREE" $drs_dispatch/dgit-live
490 ln -sf $tmp/git $drs_dispatch/repos
491 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
492 mkdir -p $drs_dispatch/keyrings
493 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
494 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
495 ln -sf /bin/true $drs_dispatch/policy-hook
500 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
501 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
502 t-git-config dgit-distro.test-dummy.git-create true
503 t-git-config dgit-distro.test-dummy.git-url \
504 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
506 t-git-config dgit-distro.test-dummy.diverts.drs /drs
507 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
508 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
509 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
510 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
512 echo 'no-such-package* drs' >$drs_dispatch/diverts
516 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
519 t-policy-nonexist () {
520 ln -sf no-such-file-or-directory $drs_dispatch/policy-hook
525 policyhook=${DGIT_INFRA_PFX}$policyhook
528 *) policyhook=`type -P $policyhook` ;;
530 ln -sf "$policyhook" $drs_dispatch/policy-hook
535 t-policy dgit-repos-policy-debian
538 t-policy-admin create-db
541 t-policy-periodic () {
542 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
543 test-dummy $drs_dispatch '' --cron
550 export DGIT_TEST_TESTNAME="$testname"
558 t-chain-test "${t#*-}"