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 local triedpush=`git rev-parse HEAD`
81 t-expect-fail "$mpat" "$@"
83 diff $tmp/show-refs.{pre,post}-push
85 t-git-objects-not-present '' $triedpush
87 eval "$t_expect_push_fail_hook"
90 t-git-objects-not-present () {
91 # t-git-objects-not-present GITDIR|'' OBJID [...]
92 # specifying '' means the repo for package $p
93 local gitdir="${1-$tmp/git/$p.git}"
95 if ! [ -e "$gitdir" ]; then return; fi
98 t-expect-fail 'unable to find' \
104 local whichoutput=$1; shift
105 local outputfile="$tmp/show-refs.$whichoutput"
108 if test -d $tmp/git/$p.git; then
116 local edittree=$1.edit
117 if test -d "$edittree"; then
118 cp -al "$edittree"/* .
126 t-untar $troot/worktrees/${p}_$1
133 local gs=$troot/git-srcs/${p}_$v.git
134 (set -e; cd $tmp/git; t-untar $gs)
139 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
143 local now=`git rev-parse HEAD`
144 local ancestor=`git rev-parse $1^{}`
145 local mbase=`git merge-base $ancestor $now`
146 if [ x$mbase != x$ancestor ]; then
147 fail "not ff $ancestor..$now, $mbase != $ancestor"
151 t-prep-newpackage () {
158 if ! git-show-ref --verify --quiet refs/heads/master; then
159 git branch -m dgit/sid master
167 mkdir -p $tmp/aq $tmp/mirror/pool/main
171 >$tmp/aq/package.$suite.$p
172 t-archive-updated $suite $p
174 >$tmp/aq/package.new.$p
175 t-archive-updated new $p
177 ln -s sid $tmp/aq/dsc_in_suite/unstable
178 cat <<'END' >$tmp/aq/suites
181 "archive" : "ftp-master",
189 "dakname" : "unstable"
195 t-archive-updated () {
198 local suitedir=$tmp/aq/dsc_in_suite/$suite
200 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
204 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
212 print to_json \@v or die $!;
217 t-archive-process-incoming () {
219 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
220 t-archive-query "$suite"
225 local dscf=main/${p}_${v}.dsc
226 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
227 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
228 t-archive-updated $suite $p
234 local dscf=${p}_$2.dsc
235 rm -f $tmp/mirror/pool/main/${p}_*
236 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
240 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
243 t-git-dir-time-passes () {
244 touch -d 'last year' $tmp/git/$p.git
248 local gitdir=$tmp/git/$p.git
251 if test -e "$gitdir"; then fail "$gitdir exists"; fi
254 public) wantstat='7[75]5' ;;
255 secret) wantstat='7[70]0' ;;
256 *) fail "$1 t-git-dir-check ?" ;;
258 gotstat=`stat -c%a $gitdir`
260 *$wantstat) return ;;
261 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
265 t-rm-dput-dropping () {
266 rm -f $tmp/${p}_${v}_*.upload
270 local dgit=${DGIT_TEST-dgit}
272 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
273 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
274 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
276 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
281 diff --exclude=.git --exclude=.pc -ruN $*
284 t-cloned-fetched-good () {
285 t-diff-nogit ../extract/$p-${v%-*} .
286 t-clean-on-branch dgit/sid
289 refs/heads/dgit/sid \
290 refs/remotes/dgit/dgit/sid
291 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
295 printf "%s\n" "$1" >$tmp/t.want
298 diff $tmp/t.want $tmp/t.got
301 t-clean-on-branch () {
302 t-output "## $1" git status -b --porcelain
309 *) fail "t-git-get-ref bad $ref" ;;
311 (git show-ref -d $1 || test $? = 1) | perl -ne '
312 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
313 END { print "$x\n" if length $x; }
319 local val=`t-git-get-ref $name`
320 t-ref-same-val "$name" $val
324 local val=`git rev-parse HEAD`
325 t-ref-same-val HEAD $val
334 *) fail "ref varies: $name: $val != $t_ref_val" ;;
339 t-refs-same-start () {
353 val=`t-git-get-ref $g >$tmp/t.refx`
354 if [ "x$val" != x ]; then
355 fail "ref $g unexpectedly exists ($val)"
361 echo refs/tags/debian/${v//\~/_}
370 refs/remotes/dgit/dgit/sid
372 refs/heads/dgit/unstable \
373 refs/remotes/dgit/dgit/unstable
374 (set -e; cd $tmp/git/$p.git
381 git verify-tag `t-v-tag`
388 use Dpkg::Control::Hash;
389 my $h = new Dpkg::Control::Hash allow_pgp=>1;
390 $h->parse(\*STDIN,"'"$file"'");
391 my $val = $h->{"'$field'"},"\n";
392 die "'"$file $field"'" unless defined $val;
404 *) '$var'="$tstunt:$'$var'" ;;
410 local tstunt=$tmp/tstunt
411 t-stunt-envvar PATH $tstunt
412 t-stunt-envvar PERLLIB $tstunt
416 local d="$tstunt/${f%/*}"
418 ln -sf "$troot/tstunt/$f" "$d"/.
422 t-tstunt-parsechangelog () {
423 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
427 local dsc=${p}_${v}.dsc
428 local val=`t-822-field $tmp/incoming/$dsc Dgit`
429 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
430 t-ref-same-val $dsc "$val"
437 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
444 dch -v$v --distribution unstable "$1"
445 git add debian/changelog
447 revision=$(( $revision + 1 ))
451 git config --global "$@"
455 export DGIT_TEST_TROOT=$troot
456 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
457 t-git-config dgit-distro.test-dummy.git-check true
458 t-git-config dgit-distro.test-dummy.git-create true
459 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
460 cp $root/tests/suites $tmp/.
462 drs_dispatch=$tmp/distro=test-dummy
464 ln -sf $root $drs_dispatch/dgit-live
465 ln -sf $tmp/git $drs_dispatch/repos
466 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
467 mkdir -p $drs_dispatch/keyrings
468 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
469 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
470 ln -sf /bin/true $drs_dispatch/policy-hook
475 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
476 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
477 t-git-config dgit-distro.test-dummy.git-create true
478 t-git-config dgit-distro.test-dummy.git-url \
479 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
481 t-git-config dgit-distro.test-dummy.diverts.drs /drs
482 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
483 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
484 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
485 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
487 echo 'no-such-package* drs' >$drs_dispatch/diverts
491 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
496 ln -sf ${DGIT_INFRA_PFX}$policyhook \
497 $drs_dispatch/policy-hook
502 t-policy dgit-repos-policy-debian
505 t-policy-admin create-db
508 t-policy-periodic () {
509 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
510 test-dummy $drs_dispatch '' --cron
517 export DGIT_TEST_TESTNAME="$testname"
525 t-chain-test "${t#*-}"