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 gotstatus=${PIPESTATUS[0]}
65 $grepper -e "$mpat" $tmp/t.output ||false
69 local whichoutput=$1; shift
70 local outputfile="$tmp/show-refs.$whichoutput"
73 if test -d $tmp/git/$p.git; then
81 local edittree=$1.edit
82 if test -d "$edittree"; then
83 cp -al "$edittree"/* .
91 t-untar $troot/worktrees/${p}_$1
98 local gs=$troot/git-srcs/${p}_$v.git
99 (set -e; cd $tmp/git; t-untar $gs)
104 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
108 local now=`git rev-parse HEAD`
109 local ancestor=`git rev-parse $1^{}`
110 local mbase=`git merge-base $ancestor $now`
111 if [ x$mbase != x$ancestor ]; then
112 fail "not ff $ancestor..$now, $mbase != $ancestor"
116 t-prep-newpackage () {
123 if ! git-show-ref --verify --quiet refs/heads/master; then
124 git branch -m dgit/sid master
132 mkdir -p $tmp/aq $tmp/mirror/pool/main
136 >$tmp/aq/package.$suite.$p
137 t-archive-updated $suite $p
139 >$tmp/aq/package.new.$p
140 t-archive-updated new $p
142 ln -s sid $tmp/aq/dsc_in_suite/unstable
143 cat <<'END' >$tmp/aq/suites
146 "archive" : "ftp-master",
154 "dakname" : "unstable"
160 t-archive-updated () {
163 local suitedir=$tmp/aq/dsc_in_suite/$suite
165 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
169 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
177 print to_json \@v or die $!;
182 t-archive-process-incoming () {
184 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
185 t-archive-query "$suite"
190 local dscf=main/${p}_${v}.dsc
191 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
192 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
193 t-archive-updated $suite $p
199 local dscf=${p}_$2.dsc
200 rm -f $tmp/mirror/pool/main/${p}_*
201 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
205 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
208 t-git-dir-time-passes () {
209 touch -d 'last year' $tmp/git/$p.git
213 local gitdir=$tmp/git/$p.git
216 if test -e "$gitdir"; then fail "$gitdir exists"; fi
219 public) wantstat='7[75]5' ;;
220 secret) wantstat='7[70]0' ;;
221 *) fail "$1 t-git-dir-check ?" ;;
223 gotstat=`stat -c%a $gitdir`
225 *$wantstat) return ;;
226 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
230 t-rm-dput-dropping () {
231 rm -f $tmp/${p}_${v}_*.upload
235 local dgit=${DGIT_TEST-dgit}
237 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
238 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
239 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
241 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
246 diff --exclude=.git --exclude=.pc -ruN $*
249 t-cloned-fetched-good () {
250 t-diff-nogit ../extract/$p-${v%-*} .
251 t-clean-on-branch dgit/sid
254 refs/heads/dgit/sid \
255 refs/remotes/dgit/dgit/sid
256 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
260 printf "%s\n" "$1" >$tmp/t.want
263 diff $tmp/t.want $tmp/t.got
266 t-clean-on-branch () {
267 t-output "## $1" git status -b --porcelain
274 *) fail "t-git-get-ref bad $ref" ;;
276 (git show-ref -d $1 || test $? = 1) | perl -ne '
277 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
278 END { print "$x\n" if length $x; }
284 local val=`t-git-get-ref $name`
285 t-ref-same-val "$name" $val
289 local val=`git rev-parse HEAD`
290 t-ref-same-val HEAD $val
299 *) fail "ref varies: $name: $val != $t_ref_val" ;;
304 t-refs-same-start () {
318 val=`t-git-get-ref $g >$tmp/t.refx`
319 if [ "x$val" != x ]; then
320 fail "ref $g unexpectedly exists ($val)"
326 echo refs/tags/debian/${v//\~/_}
335 refs/remotes/dgit/dgit/sid
337 refs/heads/dgit/unstable \
338 refs/remotes/dgit/dgit/unstable
339 (set -e; cd $tmp/git/$p.git
346 git verify-tag `t-v-tag`
353 use Dpkg::Control::Hash;
354 my $h = new Dpkg::Control::Hash allow_pgp=>1;
355 $h->parse(\*STDIN,"'"$file"'");
356 my $val = $h->{"'$field'"},"\n";
357 die "'"$file $field"'" unless defined $val;
369 *) '$var'="$tstunt:$'$var'" ;;
375 local tstunt=$tmp/tstunt
376 t-stunt-envvar PATH $tstunt
377 t-stunt-envvar PERLLIB $tstunt
381 local d="$tstunt/${f%/*}"
383 ln -sf "$troot/tstunt/$f" "$d"/.
387 t-tstunt-parsechangelog () {
388 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
392 local dsc=${p}_${v}.dsc
393 local val=`t-822-field $tmp/incoming/$dsc Dgit`
394 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
395 t-ref-same-val $dsc "$val"
402 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
409 dch -v$v --distribution unstable "$1"
410 git add debian/changelog
412 revision=$(( $revision + 1 ))
416 git config --global "$@"
420 export DGIT_TEST_TROOT=$troot
421 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
422 t-git-config dgit-distro.test-dummy.git-check true
423 t-git-config dgit-distro.test-dummy.git-create true
424 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
425 cp $root/tests/suites $tmp/.
427 drs_dispatch=$tmp/distro=test-dummy
429 ln -sf $root $drs_dispatch/dgit-live
430 ln -sf $tmp/git $drs_dispatch/repos
431 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
432 mkdir -p $drs_dispatch/keyrings
433 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
434 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
435 ln -sf /bin/true $drs_dispatch/policy-hook
440 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
441 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
442 t-git-config dgit-distro.test-dummy.git-create true
443 t-git-config dgit-distro.test-dummy.git-url \
444 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
446 t-git-config dgit-distro.test-dummy.diverts.drs /drs
447 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
448 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
449 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
450 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
452 echo 'no-such-package* drs' >$drs_dispatch/diverts
456 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
461 ln -sf ${DGIT_INFRA_PFX}$policyhook \
462 $drs_dispatch/policy-hook
467 t-policy dgit-repos-policy-debian
470 t-policy-admin create-db
473 t-policy-periodic () {
474 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
475 test-dummy $drs_dispatch '' --cron
482 export DGIT_TEST_TESTNAME="$testname"
490 t-chain-test "${t#*-}"