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
48 LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
49 local gotstatus=${PIPESTATUS[0]}
52 egrep "$mpat" $tmp/t.output ||false
57 local edittree=$1.edit
58 if test -d "$edittree"; then
59 cp -al "$edittree"/* .
67 t-untar $troot/worktrees/${p}_$1
74 local gs=$troot/git-srcs/${p}_$v.git
75 (set -e; cd $tmp/git; t-untar $gs)
80 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
84 local now=`git rev-parse HEAD`
85 local ancestor=`git rev-parse $1^{}`
86 local mbase=`git merge-base $ancestor $now`
87 if [ x$mbase != x$ancestor ]; then
88 fail "not ff $ancestor..$now, $mbase != $ancestor"
92 t-prep-newpackage () {
99 if ! git-show-ref --verify --quiet refs/heads/master; then
100 git branch -m dgit/sid master
108 mkdir -p $tmp/aq $tmp/mirror/pool/main
112 >$tmp/aq/package.$suite.$p
113 t-archive-updated $suite $p
115 >$tmp/aq/package.new.$p
116 t-archive-updated new $p
118 ln -s sid $tmp/aq/dsc_in_suite/unstable
119 cat <<'END' >$tmp/aq/suites
122 "archive" : "ftp-master",
130 "dakname" : "unstable"
136 t-archive-updated () {
139 local suitedir=$tmp/aq/dsc_in_suite/$suite
141 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
145 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
153 print to_json \@v or die $!;
158 t-archive-process-incoming () {
160 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
161 t-archive-query "$suite"
166 local dscf=main/${p}_${v}.dsc
167 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
168 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
169 t-archive-updated $suite $p
175 local dscf=${p}_$2.dsc
176 rm -f $tmp/mirror/pool/main/${p}_*
177 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
181 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
184 t-git-dir-time-passes () {
185 touch -d 'last year' $tmp/git/$p.git
189 local gitdir=$tmp/git/$p.git
192 if test -e "$gitdir"; then fail "$gitdir exists"; fi
195 public) wantstat='7[75]5' ;;
196 secret) wantstat='7[70]0' ;;
197 *) fail "$1 t-git-dir-check ?" ;;
199 gotstat=`stat -c%a $gitdir`
201 *$wantstat) return ;;
202 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
206 t-rm-dput-dropping () {
207 rm -f $tmp/${p}_${v}_*.upload
211 local dgit=${DGIT_TEST-dgit}
213 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
214 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
215 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
217 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
222 diff --exclude=.git --exclude=.pc -ruN $*
225 t-cloned-fetched-good () {
226 t-diff-nogit ../extract/$p-${v%-*} .
227 t-clean-on-branch dgit/sid
230 refs/heads/dgit/sid \
231 refs/remotes/dgit/dgit/sid
232 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
236 printf "%s\n" "$1" >$tmp/t.want
239 diff $tmp/t.want $tmp/t.got
242 t-clean-on-branch () {
243 t-output "## $1" git status -b --porcelain
250 *) fail "t-git-get-ref bad $ref" ;;
252 (git show-ref -d $1 || test $? = 1) | perl -ne '
253 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
254 END { print "$x\n" if length $x; }
260 local val=`t-git-get-ref $name`
261 t-ref-same-val "$name" $val
265 local val=`git rev-parse HEAD`
266 t-ref-same-val HEAD $val
275 *) fail "ref varies: $name: $val != $t_ref_val" ;;
280 t-refs-same-start () {
294 val=`t-git-get-ref $g >$tmp/t.refx`
295 if [ "x$val" != x ]; then
296 fail "ref $g unexpectedly exists ($val)"
302 echo refs/tags/debian/${v//\~/_}
311 refs/remotes/dgit/dgit/sid
313 refs/heads/dgit/unstable \
314 refs/remotes/dgit/dgit/unstable
315 (set -e; cd $tmp/git/$p.git
322 git verify-tag `t-v-tag`
329 use Dpkg::Control::Hash;
330 my $h = new Dpkg::Control::Hash allow_pgp=>1;
331 $h->parse(\*STDIN,"'"$file"'");
332 my $val = $h->{"'$field'"},"\n";
333 die "'"$file $field"'" unless defined $val;
345 *) '$var'="$tstunt:$'$var'" ;;
351 local tstunt=$tmp/tstunt
352 t-stunt-envvar PATH $tstunt
353 t-stunt-envvar PERLLIB $tstunt
357 local d="$tstunt/${f%/*}"
359 ln -sf "$troot/tstunt/$f" "$d"/.
363 t-tstunt-parsechangelog () {
364 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
368 local dsc=${p}_${v}.dsc
369 local val=`t-822-field $tmp/incoming/$dsc Dgit`
370 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
371 t-ref-same-val $dsc "$val"
378 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
385 dch -v$v --distribution unstable "$1"
386 git add debian/changelog
388 revision=$(( $revision + 1 ))
392 git config --global "$@"
396 export DGIT_TEST_TROOT=$troot
397 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
398 t-git-config dgit-distro.test-dummy.git-check true
399 t-git-config dgit-distro.test-dummy.git-create true
400 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
401 cp $root/tests/suites $tmp/.
403 drs_dispatch=$tmp/distro=test-dummy
405 ln -sf $root $drs_dispatch/dgit-live
406 ln -sf $tmp/git $drs_dispatch/repos
407 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
408 mkdir -p $drs_dispatch/keyrings
409 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
410 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
411 ln -sf /bin/true $drs_dispatch/policy-hook
416 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
417 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
418 t-git-config dgit-distro.test-dummy.git-create true
419 t-git-config dgit-distro.test-dummy.git-url \
420 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
422 t-git-config dgit-distro.test-dummy.diverts.drs /drs
423 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
424 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
425 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
426 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
428 echo 'no-such-package* drs' >$drs_dispatch/diverts
432 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
437 ln -sf ${DGIT_INFRA_PFX}$policyhook \
438 $drs_dispatch/policy-hook
443 t-policy dgit-repos-policy-debian
446 t-policy-admin create-db
449 t-policy-periodic () {
450 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
451 test-dummy $drs_dispatch '' --cron
458 export DGIT_TEST_TESTNAME="$testname"
466 t-chain-test "${t#*-}"