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"
76 local whichoutput=$1; shift
77 local outputfile="$tmp/show-refs.$whichoutput"
80 if test -d $tmp/git/$p.git; then
88 local edittree=$1.edit
89 if test -d "$edittree"; then
90 cp -al "$edittree"/* .
98 t-untar $troot/worktrees/${p}_$1
105 local gs=$troot/git-srcs/${p}_$v.git
106 (set -e; cd $tmp/git; t-untar $gs)
111 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
115 local now=`git rev-parse HEAD`
116 local ancestor=`git rev-parse $1^{}`
117 local mbase=`git merge-base $ancestor $now`
118 if [ x$mbase != x$ancestor ]; then
119 fail "not ff $ancestor..$now, $mbase != $ancestor"
123 t-prep-newpackage () {
130 if ! git-show-ref --verify --quiet refs/heads/master; then
131 git branch -m dgit/sid master
139 mkdir -p $tmp/aq $tmp/mirror/pool/main
143 >$tmp/aq/package.$suite.$p
144 t-archive-updated $suite $p
146 >$tmp/aq/package.new.$p
147 t-archive-updated new $p
149 ln -s sid $tmp/aq/dsc_in_suite/unstable
150 cat <<'END' >$tmp/aq/suites
153 "archive" : "ftp-master",
161 "dakname" : "unstable"
167 t-archive-updated () {
170 local suitedir=$tmp/aq/dsc_in_suite/$suite
172 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
176 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
184 print to_json \@v or die $!;
189 t-archive-process-incoming () {
191 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
192 t-archive-query "$suite"
197 local dscf=main/${p}_${v}.dsc
198 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
199 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
200 t-archive-updated $suite $p
206 local dscf=${p}_$2.dsc
207 rm -f $tmp/mirror/pool/main/${p}_*
208 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
212 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
215 t-git-dir-time-passes () {
216 touch -d 'last year' $tmp/git/$p.git
220 local gitdir=$tmp/git/$p.git
223 if test -e "$gitdir"; then fail "$gitdir exists"; fi
226 public) wantstat='7[75]5' ;;
227 secret) wantstat='7[70]0' ;;
228 *) fail "$1 t-git-dir-check ?" ;;
230 gotstat=`stat -c%a $gitdir`
232 *$wantstat) return ;;
233 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
237 t-rm-dput-dropping () {
238 rm -f $tmp/${p}_${v}_*.upload
242 local dgit=${DGIT_TEST-dgit}
244 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
245 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
246 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
248 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
253 diff --exclude=.git --exclude=.pc -ruN $*
256 t-cloned-fetched-good () {
257 t-diff-nogit ../extract/$p-${v%-*} .
258 t-clean-on-branch dgit/sid
261 refs/heads/dgit/sid \
262 refs/remotes/dgit/dgit/sid
263 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
267 printf "%s\n" "$1" >$tmp/t.want
270 diff $tmp/t.want $tmp/t.got
273 t-clean-on-branch () {
274 t-output "## $1" git status -b --porcelain
281 *) fail "t-git-get-ref bad $ref" ;;
283 (git show-ref -d $1 || test $? = 1) | perl -ne '
284 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
285 END { print "$x\n" if length $x; }
291 local val=`t-git-get-ref $name`
292 t-ref-same-val "$name" $val
296 local val=`git rev-parse HEAD`
297 t-ref-same-val HEAD $val
306 *) fail "ref varies: $name: $val != $t_ref_val" ;;
311 t-refs-same-start () {
325 val=`t-git-get-ref $g >$tmp/t.refx`
326 if [ "x$val" != x ]; then
327 fail "ref $g unexpectedly exists ($val)"
333 echo refs/tags/debian/${v//\~/_}
342 refs/remotes/dgit/dgit/sid
344 refs/heads/dgit/unstable \
345 refs/remotes/dgit/dgit/unstable
346 (set -e; cd $tmp/git/$p.git
353 git verify-tag `t-v-tag`
360 use Dpkg::Control::Hash;
361 my $h = new Dpkg::Control::Hash allow_pgp=>1;
362 $h->parse(\*STDIN,"'"$file"'");
363 my $val = $h->{"'$field'"},"\n";
364 die "'"$file $field"'" unless defined $val;
376 *) '$var'="$tstunt:$'$var'" ;;
382 local tstunt=$tmp/tstunt
383 t-stunt-envvar PATH $tstunt
384 t-stunt-envvar PERLLIB $tstunt
388 local d="$tstunt/${f%/*}"
390 ln -sf "$troot/tstunt/$f" "$d"/.
394 t-tstunt-parsechangelog () {
395 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
399 local dsc=${p}_${v}.dsc
400 local val=`t-822-field $tmp/incoming/$dsc Dgit`
401 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
402 t-ref-same-val $dsc "$val"
409 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
416 dch -v$v --distribution unstable "$1"
417 git add debian/changelog
419 revision=$(( $revision + 1 ))
423 git config --global "$@"
427 export DGIT_TEST_TROOT=$troot
428 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
429 t-git-config dgit-distro.test-dummy.git-check true
430 t-git-config dgit-distro.test-dummy.git-create true
431 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
432 cp $root/tests/suites $tmp/.
434 drs_dispatch=$tmp/distro=test-dummy
436 ln -sf $root $drs_dispatch/dgit-live
437 ln -sf $tmp/git $drs_dispatch/repos
438 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
439 mkdir -p $drs_dispatch/keyrings
440 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
441 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
442 ln -sf /bin/true $drs_dispatch/policy-hook
447 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
448 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
449 t-git-config dgit-distro.test-dummy.git-create true
450 t-git-config dgit-distro.test-dummy.git-url \
451 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
453 t-git-config dgit-distro.test-dummy.diverts.drs /drs
454 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
455 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
456 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
457 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
459 echo 'no-such-package* drs' >$drs_dispatch/diverts
463 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
468 ln -sf ${DGIT_INFRA_PFX}$policyhook \
469 $drs_dispatch/policy-hook
474 t-policy dgit-repos-policy-debian
477 t-policy-admin create-db
480 t-policy-periodic () {
481 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
482 test-dummy $drs_dispatch '' --cron
489 export DGIT_TEST_TESTNAME="$testname"
497 t-chain-test "${t#*-}"