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"
88 mkdir -p $tmp/aq $tmp/mirror/pool/main
89 mkdir -p $tmp/aq/dsc_in_suite $tmp/aq/dsc_in_suite/sid
92 >$tmp/aq/package.$suite.$p
93 t-archive-updated $suite $p
95 ln -s sid $tmp/aq/dsc_in_suite/unstable
96 cat <<'END' >$tmp/aq/suites
99 "archive" : "ftp-master",
107 "dakname" : "unstable"
113 t-archive-updated () {
116 perl <$tmp/aq/package.$suite.$p >$tmp/aq/dsc_in_suite/$suite/$p -wne '
120 m{^(\S+) (\w+) ([^ \t/]+)/(\S+)} or die;
128 print to_json \@v or die $!;
133 t-archive-process-incoming () {
134 mv incoming/${p}_${v}[._]* mirror/pool/main/
139 local dscf=main/${p}_${v}.dsc
140 local sha=`sha256sum <mirror/pool/$dscf`
141 echo "${v} ${sha% -} $dscf" >>$tmp/aq/package.sid.${p}
142 t-archive-updated sid $p
148 local dscf=${p}_$2.dsc
149 rm -f $tmp/mirror/pool/main/${p}_*
150 ln $troot/pkg-srcs/${p}_${2%-*}* $tmp/mirror/pool/main/
154 (set -e; cd $tmp/extract; dpkg-source -x ../mirror/pool/main/$dscf)
158 local dgit=${DGIT_TEST-dgit}
160 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
161 $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
162 -dtest-dummy $DGIT_TEST_OPTS ${DGIT_TEST_DEBUG--D} \
164 : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
169 diff --exclude=.git --exclude=.pc -ruN $*
172 t-cloned-fetched-good () {
173 t-diff-nogit ../extract/$p-${v%-*} .
174 t-clean-on-branch dgit/sid
177 refs/heads/dgit/sid \
178 refs/remotes/dgit/dgit/sid
179 t-refs-notexist dgit/unstable remotes/dgit/dgit/unstable
183 printf "%s\n" "$1" >$tmp/t.want
186 diff $tmp/t.want $tmp/t.got
189 t-clean-on-branch () {
190 t-output "## $1" git status -b --porcelain
195 git show-ref -d $1 | perl -ne '
196 $x = $1 if m#^(\w+) \Q'$1'\E(?:\^\{\})?$#;
197 END { print "$x\n" if length $x; }
203 local val=`t-git-get-ref $name`
204 t-ref-same-val "$name" $val
208 local val=`git rev-parse HEAD`
209 t-ref-same-val HEAD $val
218 *) fail "ref varies: $name: $val != $t_ref_val" ;;
223 t-refs-same-start () {
237 val=`t-git-get-ref $g >$tmp/t.refx`
238 if [ "x$val" != x ]; then
239 fail "ref $g unexpectedly exists ($val)"
245 echo refs/tags/debian/${v//\~/_}
254 refs/remotes/dgit/dgit/sid
256 refs/heads/dgit/unstable \
257 refs/remotes/dgit/dgit/unstable
258 (set -e; cd $tmp/git/$p.git
265 git verify-tag `t-v-tag`
272 use Dpkg::Control::Hash;
273 my $h = new Dpkg::Control::Hash allow_pgp=>1;
274 $h->parse(\*STDIN,"'"$file"'");
275 my $val = $h->{"'$field'"},"\n";
276 die "'"$file $field"'" unless defined $val;
282 local dsc=${p}_${v}.dsc
283 local val=`t-822-field $tmp/incoming/$dsc Dgit`
284 perl -e '$_=shift @ARGV; die "$dsc Dgit $_ ?" unless m/^\w+\b/;' "$val"
285 t-ref-same-val $dsc "$val"
291 (cd $troot/pkg-srcs; debdiff ${p}_${v1}.dsc ${p}_${v2}.dsc) \
296 git config --global "$@"
300 export DGIT_TEST_TROOT=$troot
301 export DGIT_TEST_TMP=$tmp
302 t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
303 t-git-config dgit-distro.test-dummy.git-check true
304 t-git-config dgit-distro.test-dummy.git-create true
305 cp $root/tests/gnupg/{dd.gpg,dm.gpg,dm.txt} $tmp/.
306 cp $root/tests/suites $tmp/.
311 t-git-config dgit-distro.test-dummy.ssh "$troot/dsd-ssh"
312 t-git-config dgit-distro.test-dummy.git-check ssh-cmd
313 t-git-config dgit-distro.test-dummy.git-create true
314 t-git-config dgit-distro.test-dummy.git-url \
315 "ext::$troot/dsd-ssh X %S /dgit/test-dummy/repos"
317 t-git-config dgit-distro.test-dummy.diverts.drs /drs
318 t-git-config dgit-distro.test-dummy/drs.ssh "$troot/ssh"
319 t-git-config dgit-distro.test-dummy/drs.git-url $tmp/git
320 t-git-config dgit-distro.test-dummy/drs.git-check ssh-cmd
321 t-git-config dgit-distro.test-dummy/drs.git-create ssh-cmd
323 dsd_dispatch=$tmp/dispatch-dir/distro=test-dummy
324 mkdir -p $dsd_dispatch
325 ln -sf $root $dsd_dispatch/dgit-live
326 ln -sf $tmp/git $dsd_dispatch/repos
327 ln -sf $tmp/suites $tmp/dm.txt $dsd_dispatch/
328 mkdir -p $dsd_dispatch/keyrings
329 ln -sf $tmp/dd.gpg $dsd_dispatch/keyrings/debian-keyring.gpg
330 ln -sf $tmp/dm.gpg $dsd_dispatch/keyrings/debian-maintainers.gpg
331 ln -sf /bin/true $dsd_dispatch/policy-hook
333 echo 'no-such-package* drs' >$dsd_dispatch/diverts
340 export DGIT_TEST_TESTNAME="$testname"
348 t-chain-test "${t#*-}"