10 : ${DGIT_TEST_DEBUG:=-D}
11 export DGIT_TEST_DEBUG
15 testname="${DGIT_TEST_TESTNAME-${0##*/}}"
18 if [ x"$tmp" = x ]; then
20 tmp=tests/tmp/$testname
33 cp $troot/gnupg/* $tmp/gnupg
34 chmod go-rw $tmp/gnupg/*
36 mkdir -p $tmp/incoming
37 cat <<END >$tmp/dput.cf
40 incoming = $tmp/incoming
45 local mpat="$1"; shift
46 LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
47 test ${PIPESTATUS[0]} != 0
48 egrep "$mpat" $tmp/t.output ||false
53 local edittree=$1.edit
54 if test -d "$edittree"; then
55 cp -al "$edittree"/* .
63 t-untar $troot/worktrees/${p}_$1
70 local gs=$troot/git-srcs/${p}_$v.git
71 (set -e; cd $tmp/git; t-untar $gs)
76 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
80 local now=`git rev-parse HEAD`
81 local ancestor=`git rev-parse $1^{}`
82 local mbase=`git merge-base $ancestor $now`
83 if [ x$mbase != x$ancestor ]; then
84 fail "not ff $ancestor..$now, $mbase != $ancestor"
88 t-prep-newpackage () {
95 if ! git-show-ref --verify --quiet refs/heads/master; then
96 git branch -m dgit/sid master
104 mkdir -p $tmp/aq $tmp/mirror/pool/main
108 >$tmp/aq/package.$suite.$p
109 t-archive-updated $suite $p
111 >$tmp/aq/package.new.$p
112 t-archive-updated new $p
114 ln -s sid $tmp/aq/dsc_in_suite/unstable
115 cat <<'END' >$tmp/aq/suites
118 "archive" : "ftp-master",
126 "dakname" : "unstable"
132 t-archive-updated () {
135 local suitedir=$tmp/aq/dsc_in_suite/$suite
137 perl <$tmp/aq/package.$suite.$p >$suitedir/$p -wne '
141 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
149 print to_json \@v or die $!;
154 t-archive-process-incoming () {
156 mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
157 t-archive-query "$suite"
162 local dscf=main/${p}_${v}.dsc
163 local sha=`sha256sum <$tmp/mirror/pool/$dscf`
164 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.$suite.${p}
165 t-archive-updated $suite $p
171 local dscf=${p}_$2.dsc
172 rm -f $tmp/mirror/pool/main/${p}_*
173 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
177 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
180 t-git-dir-time-passes () {
181 touch -d 'last year' $tmp/git/$p.git
185 local gitdir=$tmp/git/$p.git
188 if test -e "$gitdir"; then fail "$gitdir exists"; fi
191 public) wantstat='7[75]5' ;;
192 secret) wantstat='7[70]0' ;;
193 *) fail "$1 t-git-dir-check ?" ;;
195 gotstat=`stat -c%a $gitdir`
197 *$wantstat) return ;;
198 *) fail "$gitdir has mode $gotstat, expected $wantstat" ;;
202 t-rm-dput-dropping () {
203 rm -f $tmp/${p}_${v}_*.upload
207 local dgit=${DGIT_TEST-dgit}
209 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
210 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
211 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
213 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
218 diff --exclude=.git --exclude=.pc -ruN $*
221 t-cloned-fetched-good () {
222 t-diff-nogit ../extract/$p-${v%-*} .
223 t-clean-on-branch dgit/sid
226 refs/heads/dgit/sid \
227 refs/remotes/dgit/dgit/sid
228 t-refs-notexist refs/dgit/unstable refs/remotes/dgit/dgit/unstable
232 printf "%s\n" "$1" >$tmp/t.want
235 diff $tmp/t.want $tmp/t.got
238 t-clean-on-branch () {
239 t-output "## $1" git status -b --porcelain
244 git show-ref -d $1 | perl -ne '
245 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
246 END { print "$x\n" if length $x; }
252 local val=`t-git-get-ref $name`
253 t-ref-same-val "$name" $val
257 local val=`git rev-parse HEAD`
258 t-ref-same-val HEAD $val
267 *) fail "ref varies: $name: $val != $t_ref_val" ;;
272 t-refs-same-start () {
286 val=`t-git-get-ref $g >$tmp/t.refx`
287 if [ "x$val" != x ]; then
288 fail "ref $g unexpectedly exists ($val)"
294 echo refs/tags/debian/${v//\~/_}
303 refs/remotes/dgit/dgit/sid
305 refs/heads/dgit/unstable \
306 refs/remotes/dgit/dgit/unstable
307 (set -e; cd $tmp/git/$p.git
314 git verify-tag `t-v-tag`
321 use Dpkg::Control::Hash;
322 my $h = new Dpkg::Control::Hash allow_pgp=>1;
323 $h->parse(\*STDIN,"'"$file"'");
324 my $val = $h->{"'$field'"},"\n";
325 die "'"$file $field"'" unless defined $val;
337 *) '$var'="$tstunt:$'$var'" ;;
343 local tstunt=$tmp/tstunt
344 t-stunt-envvar PATH $tstunt
345 t-stunt-envvar PERLLIB $tstunt
349 local d="$tstunt/${f%/*}"
351 ln -sf "$troot/tstunt/$f" "$d"/.
355 t-tstunt-parsechangelog () {
356 t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
360 local dsc=${p}_${v}.dsc
361 local val=`t-822-field $tmp/incoming/$dsc Dgit`
362 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
363 t-ref-same-val $dsc "$val"
369 (cd $troot/pkg-srcs; debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc) \
376 dch -v$v --distribution unstable "$1"
377 git add debian/changelog
379 revision=$(( $revision + 1 ))
383 git config --global "$@"
387 export DGIT_TEST_TROOT=$troot
388 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
389 t-git-config dgit-distro.test-dummy.git-check true
390 t-git-config dgit-distro.test-dummy.git-create true
391 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
392 cp $root/tests/suites $tmp/.
394 drs_dispatch=$tmp/distro=test-dummy
396 ln -sf $root $drs_dispatch/dgit-live
397 ln -sf $tmp/git $drs_dispatch/repos
398 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
399 mkdir -p $drs_dispatch/keyrings
400 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
401 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
402 ln -sf /bin/true $drs_dispatch/policy-hook
407 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
408 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
409 t-git-config dgit-distro.test-dummy.git-create true
410 t-git-config dgit-distro.test-dummy.git-url \
411 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
413 t-git-config dgit-distro.test-dummy.diverts.drs /drs
414 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
415 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
416 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
417 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
419 echo 'no-such-package* drs' >$drs_dispatch/diverts
423 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
428 ln -sf ${DGIT_INFRA_PFX}$policyhook \
429 $drs_dispatch/policy-hook
434 t-policy dgit-repos-policy-debian
437 t-policy-admin create-db
440 t-policy-periodic () {
441 ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
442 test-dummy $drs_dispatch '' --cron
449 export DGIT_TEST_TESTNAME="$testname"
457 t-chain-test "${t#*-}"