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
56 local whichoutput=$1; shift
57 local outputfile="$tmp/show-refs.$whichoutput"
60 if test -d $tmp/git/$p.git; then
68 local edittree=$1.edit
69 if test -d "$edittree"; then
70 cp -al "$edittree"/* .
78 t-untar $troot/worktrees/${p}_$1
85 local gs=$troot/git-srcs/${p}_$v.git
86 (set -e; cd $tmp/git; t-untar $gs)
91 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
95 local now=`git rev-parse HEAD`
96 local ancestor=`git rev-parse $1^{}`
97 local mbase=`git merge-base $ancestor $now`
98 if [ x$mbase != x$ancestor ]; then
99 fail "not ff $ancestor..$now, $mbase != $ancestor"
103 t-prep-newpackage () {
110 if ! git-show-ref --verify --quiet refs/heads/master; then
111 git branch -m dgit/sid master
119 mkdir -p $tmp/aq $tmp/mirror/pool/main
123 >$tmp/aq/package.$suite.$p
124 t-archive-updated $suite $p
126 >$tmp/aq/package.new.$p
127 t-archive-updated new $p
129 ln -s sid $tmp/aq/dsc_in_suite/unstable
130 cat <<'END' >$tmp/aq/suites
133 "archive" : "ftp-master",
141 "dakname" : "unstable"
147 t-archive-updated () {
150 local suitedir=$tmp/aq/dsc_in_suite/$suite
152 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
156 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
164 print to_json \@v or die $!;
169 t-archive-process-incoming () {
171 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
172 t-archive-query "$suite"
177 local dscf=main/${p}_${v}.dsc
178 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
179 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
180 t-archive-updated $suite $p
186 local dscf=${p}_$2.dsc
187 rm -f $tmp/mirror/pool/main/${p}_*
188 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
192 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
195 t-git-dir-time-passes () {
196 touch -d 'last year' $tmp/git/$p.git
200 local gitdir=$tmp/git/$p.git
203 if test -e "$gitdir"; then fail "$gitdir exists"; fi
206 public) wantstat='7[75]5' ;;
207 secret) wantstat='7[70]0' ;;
208 *) fail "$1 t-git-dir-check ?" ;;
210 gotstat=`stat -c%a $gitdir`
212 *$wantstat) return ;;
213 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
217 t-rm-dput-dropping () {
218 rm -f $tmp/${p}_${v}_*.upload
222 local dgit=${DGIT_TEST-dgit}
224 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
225 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
226 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
228 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
233 diff --exclude=.git --exclude=.pc -ruN $*
236 t-cloned-fetched-good () {
237 t-diff-nogit ../extract/$p-${v%-*} .
238 t-clean-on-branch dgit/sid
241 refs/heads/dgit/sid \
242 refs/remotes/dgit/dgit/sid
243 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
247 printf "%s\n" "$1" >$tmp/t.want
250 diff $tmp/t.want $tmp/t.got
253 t-clean-on-branch () {
254 t-output "## $1" git status -b --porcelain
261 *) fail "t-git-get-ref bad $ref" ;;
263 (git show-ref -d $1 || test $? = 1) | perl -ne '
264 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
265 END { print "$x\n" if length $x; }
271 local val=`t-git-get-ref $name`
272 t-ref-same-val "$name" $val
276 local val=`git rev-parse HEAD`
277 t-ref-same-val HEAD $val
286 *) fail "ref varies: $name: $val != $t_ref_val" ;;
291 t-refs-same-start () {
305 val=`t-git-get-ref $g >$tmp/t.refx`
306 if [ "x$val" != x ]; then
307 fail "ref $g unexpectedly exists ($val)"
313 echo refs/tags/debian/${v//\~/_}
322 refs/remotes/dgit/dgit/sid
324 refs/heads/dgit/unstable \
325 refs/remotes/dgit/dgit/unstable
326 (set -e; cd $tmp/git/$p.git
333 git verify-tag `t-v-tag`
340 use Dpkg::Control::Hash;
341 my $h = new Dpkg::Control::Hash allow_pgp=>1;
342 $h->parse(\*STDIN,"'"$file"'");
343 my $val = $h->{"'$field'"},"\n";
344 die "'"$file $field"'" unless defined $val;
356 *) '$var'="$tstunt:$'$var'" ;;
362 local tstunt=$tmp/tstunt
363 t-stunt-envvar PATH $tstunt
364 t-stunt-envvar PERLLIB $tstunt
368 local d="$tstunt/${f%/*}"
370 ln -sf "$troot/tstunt/$f" "$d"/.
374 t-tstunt-parsechangelog () {
375 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
379 local dsc=${p}_${v}.dsc
380 local val=`t-822-field $tmp/incoming/$dsc Dgit`
381 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
382 t-ref-same-val $dsc "$val"
389 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
396 dch -v$v --distribution unstable "$1"
397 git add debian/changelog
399 revision=$(( $revision + 1 ))
403 git config --global "$@"
407 export DGIT_TEST_TROOT=$troot
408 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
409 t-git-config dgit-distro.test-dummy.git-check true
410 t-git-config dgit-distro.test-dummy.git-create true
411 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
412 cp $root/tests/suites $tmp/.
414 drs_dispatch=$tmp/distro=test-dummy
416 ln -sf $root $drs_dispatch/dgit-live
417 ln -sf $tmp/git $drs_dispatch/repos
418 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
419 mkdir -p $drs_dispatch/keyrings
420 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
421 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
422 ln -sf /bin/true $drs_dispatch/policy-hook
427 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
428 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
429 t-git-config dgit-distro.test-dummy.git-create true
430 t-git-config dgit-distro.test-dummy.git-url \
431 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
433 t-git-config dgit-distro.test-dummy.diverts.drs /drs
434 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
435 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
436 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
437 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
439 echo 'no-such-package* drs' >$drs_dispatch/diverts
443 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
448 ln -sf ${DGIT_INFRA_PFX}$policyhook \
449 $drs_dispatch/policy-hook
454 t-policy dgit-repos-policy-debian
457 t-policy-admin create-db
460 t-policy-periodic () {
461 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
462 test-dummy $drs_dispatch '' --cron
469 export DGIT_TEST_TESTNAME="$testname"
477 t-chain-test "${t#*-}"