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 export DGIT_TEST DGIT_REPOS_SERVER_TEST DGIT_SSH_DISPATCH_TEST
15 testname="${DGIT_TEST_TESTNAME-${0##*/}}"
18 if [ x"$tmp" = x ]; then
20 tmp=tests/tmp/$testname
28 export DGIT_TEST_DUMMY_DIR=$tmp
32 cp $troot/gnupg/* $tmp/gnupg
33 chmod go-rw $tmp/gnupg/*
34 export GNUPGHOME=$tmp/gnupg
36 mkdir -p $tmp/incoming
37 cat <<END >$tmp/dput.cf
40 incoming = $tmp/incoming
51 local edittree=$1.edit
52 if test -d "$edittree"; then
53 cp -al "$edittree"/* .
61 t-untar $troot/worktrees/${p}_$1
68 local gs=$troot/git-srcs/${p}_$v.git
69 (set -e; cd $tmp/git; t-untar $gs)
74 (set -e; cd $tmp/git; tar xf $troot/git-template.tar)
78 local now=`git rev-parse HEAD`
79 local ancestor=`git rev-parse $1^{}`
80 local mbase=`git merge-base $ancestor $now`
81 if [ x$mbase != x$ancestor ]; then
82 fail "not ff $ancestor..$now, $mbase != $ancestor"
86 t-prep-newpackage () {
94 git branch -m dgit/sid master
101 mkdir -p $tmp/aq $tmp/mirror/pool/main
102 mkdir -p $tmp/aq/dsc_in_suite $tmp/aq/dsc_in_suite/sid
105 >$tmp/aq/package.$suite.$p
106 t-archive-updated $suite $p
108 ln -s sid $tmp/aq/dsc_in_suite/unstable
109 cat <<'END' >$tmp/aq/suites
112 "archive" : "ftp-master",
120 "dakname" : "unstable"
126 t-archive-updated () {
129 perl <$tmp/aq/package.$suite.$p >$tmp/aq/dsc_in_suite/$suite/$p -wne '
133 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
141 print to_json \@v or die $!;
146 t-archive-process-incoming () {
147 mv incoming/${p}_${v}[._]* mirror/pool/main/
152 local dscf=main/${p}_${v}.dsc
153 local sha=`sha256sum <mirror/pool/$dscf`
154 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.sid.${p}
155 t-archive-updated sid $p
161 local dscf=${p}_$2.dsc
162 rm -f $tmp/mirror/pool/main/${p}_*
163 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
167 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
171 local dgit=${DGIT_TEST-dgit}
173 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
174 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
175 -dtest-dummy $DGIT_TEST_OPTS ${DGIT_TEST_DEBUG--D} \
177 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
182 diff --exclude=.git --exclude=.pc -ruN $*
185 t-cloned-fetched-good () {
186 t-diff-nogit ../extract/$p-${v%-*} .
187 t-clean-on-branch dgit/sid
190 refs/heads/dgit/sid \
191 refs/remotes/dgit/dgit/sid
192 t-refs-notexist dgit/unstable remotes/dgit/dgit/unstable
196 printf "%s\n" "$1" >$tmp/t.want
199 diff $tmp/t.want $tmp/t.got
202 t-clean-on-branch () {
203 t-output "## $1" git status -b --porcelain
208 git show-ref -d $1 | perl -ne '
209 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
210 END { print "$x\n" if length $x; }
216 local val=`t-git-get-ref $name`
217 t-ref-same-val "$name" $val
221 local val=`git rev-parse HEAD`
222 t-ref-same-val HEAD $val
231 *) fail "ref varies: $name: $val != $t_ref_val" ;;
236 t-refs-same-start () {
250 val=`t-git-get-ref $g >$tmp/t.refx`
251 if [ "x$val" != x ]; then
252 fail "ref $g unexpectedly exists ($val)"
258 echo refs/tags/debian/${v//\~/_}
267 refs/remotes/dgit/dgit/sid
269 refs/heads/dgit/unstable \
270 refs/remotes/dgit/dgit/unstable
271 (set -e; cd $tmp/git/$p.git
278 git verify-tag `t-v-tag`
285 use Dpkg::Control::Hash;
286 my $h = new Dpkg::Control::Hash allow_pgp=>1;
287 $h->parse(\*STDIN,"'"$file"'");
288 my $val = $h->{"'$field'"},"\n";
289 die "'"$file $field"'" unless defined $val;
295 local dsc=${p}_${v}.dsc
296 local val=`t-822-field $tmp/incoming/$dsc Dgit`
297 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
298 t-ref-same-val $dsc "$val"
304 (cd $troot/pkg-srcs; debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc) \
309 git config --global "$@"
313 export DGIT_TEST_TROOT=$troot
314 export DGIT_TEST_TMP=$tmp
315 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
316 t-git-config dgit-distro.test-dummy.git-check true
317 t-git-config dgit-distro.test-dummy.git-create true
318 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
319 cp $root/tests/suites $tmp/.
324 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
325 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
326 t-git-config dgit-distro.test-dummy.git-create true
327 t-git-config dgit-distro.test-dummy.git-url \
328 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
330 t-git-config dgit-distro.test-dummy.diverts.drs /drs
331 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
332 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
333 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
334 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
336 dsd_dispatch=$tmp/dispatch-dir/distro=test-dummy
337 mkdir -p $dsd_dispatch
338 ln -sf $root $dsd_dispatch/dgit-live
339 ln -sf $tmp/git $dsd_dispatch/repos
340 ln -sf $tmp/suites $tmp/dm.txt $dsd_dispatch/
341 mkdir -p $dsd_dispatch/keyrings
342 ln -sf $tmp/dd.gpg $dsd_dispatch/keyrings/debian-keyring.gpg
343 ln -sf $tmp/dm.gpg $dsd_dispatch/keyrings/debian-maintainers.gpg
344 ln -sf /bin/true $dsd_dispatch/policy-hook
346 echo 'no-such-package* drs' >$dsd_dispatch/diverts
353 export DGIT_TEST_TESTNAME="$testname"
361 t-chain-test "${t#*-}"