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 if test -d $tmp/git/$p.git; then
65 local edittree=$1.edit
66 if test -d "$edittree"; then
67 cp -al "$edittree"/* .
75 t-untar $troot/worktrees/${p}_$1
82 local gs=$troot/git-srcs/${p}_$v.git
83 (set -e; cd $tmp/git; t-untar $gs)
88 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
92 local now=`git rev-parse HEAD`
93 local ancestor=`git rev-parse $1^{}`
94 local mbase=`git merge-base $ancestor $now`
95 if [ x$mbase != x$ancestor ]; then
96 fail "not ff $ancestor..$now, $mbase != $ancestor"
100 t-prep-newpackage () {
107 if ! git-show-ref --verify --quiet refs/heads/master; then
108 git branch -m dgit/sid master
116 mkdir -p $tmp/aq $tmp/mirror/pool/main
120 >$tmp/aq/package.$suite.$p
121 t-archive-updated $suite $p
123 >$tmp/aq/package.new.$p
124 t-archive-updated new $p
126 ln -s sid $tmp/aq/dsc_in_suite/unstable
127 cat <<'END' >$tmp/aq/suites
130 "archive" : "ftp-master",
138 "dakname" : "unstable"
144 t-archive-updated () {
147 local suitedir=$tmp/aq/dsc_in_suite/$suite
149 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
153 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
161 print to_json \@v or die $!;
166 t-archive-process-incoming () {
168 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
169 t-archive-query "$suite"
174 local dscf=main/${p}_${v}.dsc
175 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
176 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
177 t-archive-updated $suite $p
183 local dscf=${p}_$2.dsc
184 rm -f $tmp/mirror/pool/main/${p}_*
185 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
189 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
192 t-git-dir-time-passes () {
193 touch -d 'last year' $tmp/git/$p.git
197 local gitdir=$tmp/git/$p.git
200 if test -e "$gitdir"; then fail "$gitdir exists"; fi
203 public) wantstat='7[75]5' ;;
204 secret) wantstat='7[70]0' ;;
205 *) fail "$1 t-git-dir-check ?" ;;
207 gotstat=`stat -c%a $gitdir`
209 *$wantstat) return ;;
210 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
214 t-rm-dput-dropping () {
215 rm -f $tmp/${p}_${v}_*.upload
219 local dgit=${DGIT_TEST-dgit}
221 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
222 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
223 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
225 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
230 diff --exclude=.git --exclude=.pc -ruN $*
233 t-cloned-fetched-good () {
234 t-diff-nogit ../extract/$p-${v%-*} .
235 t-clean-on-branch dgit/sid
238 refs/heads/dgit/sid \
239 refs/remotes/dgit/dgit/sid
240 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
244 printf "%s\n" "$1" >$tmp/t.want
247 diff $tmp/t.want $tmp/t.got
250 t-clean-on-branch () {
251 t-output "## $1" git status -b --porcelain
258 *) fail "t-git-get-ref bad $ref" ;;
260 (git show-ref -d $1 || test $? = 1) | perl -ne '
261 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
262 END { print "$x\n" if length $x; }
268 local val=`t-git-get-ref $name`
269 t-ref-same-val "$name" $val
273 local val=`git rev-parse HEAD`
274 t-ref-same-val HEAD $val
283 *) fail "ref varies: $name: $val != $t_ref_val" ;;
288 t-refs-same-start () {
302 val=`t-git-get-ref $g >$tmp/t.refx`
303 if [ "x$val" != x ]; then
304 fail "ref $g unexpectedly exists ($val)"
310 echo refs/tags/debian/${v//\~/_}
319 refs/remotes/dgit/dgit/sid
321 refs/heads/dgit/unstable \
322 refs/remotes/dgit/dgit/unstable
323 (set -e; cd $tmp/git/$p.git
330 git verify-tag `t-v-tag`
337 use Dpkg::Control::Hash;
338 my $h = new Dpkg::Control::Hash allow_pgp=>1;
339 $h->parse(\*STDIN,"'"$file"'");
340 my $val = $h->{"'$field'"},"\n";
341 die "'"$file $field"'" unless defined $val;
353 *) '$var'="$tstunt:$'$var'" ;;
359 local tstunt=$tmp/tstunt
360 t-stunt-envvar PATH $tstunt
361 t-stunt-envvar PERLLIB $tstunt
365 local d="$tstunt/${f%/*}"
367 ln -sf "$troot/tstunt/$f" "$d"/.
371 t-tstunt-parsechangelog () {
372 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
376 local dsc=${p}_${v}.dsc
377 local val=`t-822-field $tmp/incoming/$dsc Dgit`
378 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
379 t-ref-same-val $dsc "$val"
386 debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc || test $? = 1) \
393 dch -v$v --distribution unstable "$1"
394 git add debian/changelog
396 revision=$(( $revision + 1 ))
400 git config --global "$@"
404 export DGIT_TEST_TROOT=$troot
405 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
406 t-git-config dgit-distro.test-dummy.git-check true
407 t-git-config dgit-distro.test-dummy.git-create true
408 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
409 cp $root/tests/suites $tmp/.
411 drs_dispatch=$tmp/distro=test-dummy
413 ln -sf $root $drs_dispatch/dgit-live
414 ln -sf $tmp/git $drs_dispatch/repos
415 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
416 mkdir -p $drs_dispatch/keyrings
417 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
418 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
419 ln -sf /bin/true $drs_dispatch/policy-hook
424 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
425 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
426 t-git-config dgit-distro.test-dummy.git-create true
427 t-git-config dgit-distro.test-dummy.git-url \
428 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
430 t-git-config dgit-distro.test-dummy.diverts.drs /drs
431 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
432 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
433 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
434 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
436 echo 'no-such-package* drs' >$drs_dispatch/diverts
440 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
445 ln -sf ${DGIT_INFRA_PFX}$policyhook \
446 $drs_dispatch/policy-hook
451 t-policy dgit-repos-policy-debian
454 t-policy-admin create-db
457 t-policy-periodic () {
458 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
459 test-dummy $drs_dispatch '' --cron
466 export DGIT_TEST_TESTNAME="$testname"
474 t-chain-test "${t#*-}"