6 if [ "x$DGIT_TEST_INTREE" != x ]; then
7 : ${DGIT_TEST:=$DGIT_TEST_INTREE/dgit}
8 : ${DGIT_REPOS_SERVER_TEST:=$DGIT_TEST_INTREE/infra/dgit-repos-server}
9 : ${DGIT_SSH_DISPATCH_TEST:=$DGIT_TEST_INTREE/infra/dgit-ssh-dispatch}
10 : ${DGIT_INFRA_PFX:=$DGIT_TEST_INTREE${DGIT_TEST_INTREE:+/infra/}}
11 export DGIT_TEST DGIT_REPOS_SERVER_TEST DGIT_SSH_DISPATCH_TEST
14 : ${DGIT_TEST_DEBUG:=-D}
15 export DGIT_TEST_DEBUG
19 testname="${DGIT_TEST_TESTNAME-${0##*/}}"
22 if [ x"$tmp" = x ]; then
24 tmp=tests/tmp/$testname
32 export DGIT_TEST_DUMMY_DIR=$tmp
36 cp $troot/gnupg/* $tmp/gnupg
37 chmod go-rw $tmp/gnupg/*
38 export GNUPGHOME=$tmp/gnupg
40 mkdir -p $tmp/incoming
41 cat <<END >$tmp/dput.cf
44 incoming = $tmp/incoming
54 local mpat="$1"; shift
55 LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
56 test ${PIPESTATUS[0]} != 0
57 egrep "$mpat" $tmp/t.output ||false
62 local edittree=$1.edit
63 if test -d "$edittree"; then
64 cp -al "$edittree"/* .
72 t-untar $troot/worktrees/${p}_$1
79 local gs=$troot/git-srcs/${p}_$v.git
80 (set -e; cd $tmp/git; t-untar $gs)
85 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
89 local now=`git rev-parse HEAD`
90 local ancestor=`git rev-parse $1^{}`
91 local mbase=`git merge-base $ancestor $now`
92 if [ x$mbase != x$ancestor ]; then
93 fail "not ff $ancestor..$now, $mbase != $ancestor"
97 t-prep-newpackage () {
105 git branch -m dgit/sid master
112 mkdir -p $tmp/aq $tmp/mirror/pool/main
113 mkdir -p $tmp/aq/dsc_in_suite $tmp/aq/dsc_in_suite/sid
116 >$tmp/aq/package.$suite.$p
117 t-archive-updated $suite $p
119 ln -s sid $tmp/aq/dsc_in_suite/unstable
120 cat <<'END' >$tmp/aq/suites
123 "archive" : "ftp-master",
131 "dakname" : "unstable"
137 t-archive-updated () {
140 perl <$tmp/aq/package.$suite.$p >$tmp/aq/dsc_in_suite/$suite/$p -wne '
144 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
152 print to_json \@v or die $!;
157 t-archive-process-incoming () {
158 mv incoming/${p}_${v}[._]* mirror/pool/main/
163 local dscf=main/${p}_${v}.dsc
164 local sha=`sha256sum <mirror/pool/$dscf`
165 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.sid.${p}
166 t-archive-updated sid $p
172 local dscf=${p}_$2.dsc
173 rm -f $tmp/mirror/pool/main/${p}_*
174 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
178 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
182 local dgit=${DGIT_TEST-dgit}
184 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
185 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
186 -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
188 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
193 diff --exclude=.git --exclude=.pc -ruN $*
196 t-cloned-fetched-good () {
197 t-diff-nogit ../extract/$p-${v%-*} .
198 t-clean-on-branch dgit/sid
201 refs/heads/dgit/sid \
202 refs/remotes/dgit/dgit/sid
203 t-refs-notexist dgit/unstable remotes/dgit/dgit/unstable
207 printf "%s\n" "$1" >$tmp/t.want
210 diff $tmp/t.want $tmp/t.got
213 t-clean-on-branch () {
214 t-output "## $1" git status -b --porcelain
219 git show-ref -d $1 | perl -ne '
220 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
221 END { print "$x\n" if length $x; }
227 local val=`t-git-get-ref $name`
228 t-ref-same-val "$name" $val
232 local val=`git rev-parse HEAD`
233 t-ref-same-val HEAD $val
242 *) fail "ref varies: $name: $val != $t_ref_val" ;;
247 t-refs-same-start () {
261 val=`t-git-get-ref $g >$tmp/t.refx`
262 if [ "x$val" != x ]; then
263 fail "ref $g unexpectedly exists ($val)"
269 echo refs/tags/debian/${v//\~/_}
278 refs/remotes/dgit/dgit/sid
280 refs/heads/dgit/unstable \
281 refs/remotes/dgit/dgit/unstable
282 (set -e; cd $tmp/git/$p.git
289 git verify-tag `t-v-tag`
296 use Dpkg::Control::Hash;
297 my $h = new Dpkg::Control::Hash allow_pgp=>1;
298 $h->parse(\*STDIN,"'"$file"'");
299 my $val = $h->{"'$field'"},"\n";
300 die "'"$file $field"'" unless defined $val;
306 local dsc=${p}_${v}.dsc
307 local val=`t-822-field $tmp/incoming/$dsc Dgit`
308 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
309 t-ref-same-val $dsc "$val"
315 (cd $troot/pkg-srcs; debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc) \
320 git config --global "$@"
324 export DGIT_TEST_TROOT=$troot
325 export DGIT_TEST_TMP=$tmp
326 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
327 t-git-config dgit-distro.test-dummy.git-check true
328 t-git-config dgit-distro.test-dummy.git-create true
329 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
330 cp $root/tests/suites $tmp/.
332 drs_dispatch=$tmp/distro=test-dummy
334 ln -sf $root $drs_dispatch/dgit-live
335 ln -sf $tmp/git $drs_dispatch/repos
336 ln -sf $tmp/suites $tmp/dm.txt $drs_dispatch/
337 mkdir -p $drs_dispatch/keyrings
338 ln -sf $tmp/dd.gpg $drs_dispatch/keyrings/debian-keyring.gpg
339 ln -sf $tmp/dm.gpg $drs_dispatch/keyrings/debian-maintainers.gpg
340 ln -sf /bin/true $drs_dispatch/policy-hook
345 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
346 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
347 t-git-config dgit-distro.test-dummy.git-create true
348 t-git-config dgit-distro.test-dummy.git-url \
349 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
351 t-git-config dgit-distro.test-dummy.diverts.drs /drs
352 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
353 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
354 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
355 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
357 echo 'no-such-package* drs' >$drs_dispatch/diverts
361 ${DGIT_INFRA_PFX}dgit-repos-admin-debian --repos $tmp/git "$@"
367 ln -sf ${DGIT_INFRA_PFX}dgit-repos-policy-debian \
368 $drs_dispatch/policy-hook
371 t-policy-admin create-db
378 export DGIT_TEST_TESTNAME="$testname"
386 t-chain-test "${t#*-}"