diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/enumerate-tests | 2 | ||||
-rw-r--r-- | tests/lib | 15 | ||||
-rw-r--r-- | tests/lib-core | 6 | ||||
-rw-r--r-- | tests/lib-gdr | 2 | ||||
-rw-r--r-- | tests/lib-import-chk | 8 | ||||
-rwxr-xr-x | tests/setup/gdr-convert-gbp | 3 | ||||
-rwxr-xr-x | tests/setup/gdr-convert-gbp-noarchive | 1 | ||||
-rwxr-xr-x | tests/setup/gnupg | 6 | ||||
-rwxr-xr-x | tests/tartree-edit | 2 | ||||
-rwxr-xr-x | tests/tests/checkout | 59 | ||||
-rwxr-xr-x | tests/tests/gdr-makepatches7 | 9 | ||||
-rwxr-xr-x | tests/tests/gdr-newupstream | 8 | ||||
-rwxr-xr-x | tests/tests/gdr-viagit | 1 | ||||
-rwxr-xr-x | tests/tests/import-native | 2 | ||||
-rwxr-xr-x | tests/tests/manpages-format | 78 | ||||
-rwxr-xr-x | tests/tests/overwrite-splitbrains | 2 | ||||
-rwxr-xr-x | tests/tests/push-newrepeat | 21 | ||||
-rwxr-xr-x | tests/tests/sourceonlypolicy | 38 | ||||
-rwxr-xr-x | tests/tests/trustingpolicy-replay | 5 | ||||
-rwxr-xr-x | tests/tstunt/gpg | 18 | ||||
-rwxr-xr-x | tests/tstunt/gpg-withagent | 68 |
21 files changed, 335 insertions, 19 deletions
diff --git a/tests/enumerate-tests b/tests/enumerate-tests index 0599b69..0f37c96 100755 --- a/tests/enumerate-tests +++ b/tests/enumerate-tests @@ -42,7 +42,7 @@ finish- () { test-begin-gencontrol () { restrictions='' - dependencies='dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin' + dependencies='dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc' } restriction-gencontrol () { @@ -41,6 +41,7 @@ export DGIT_TEST_TROOT=$troot tmp=$ADTTMP if [ x"$tmp" = x ]; then + export DGIT_TEST_BYHAND=1 mkdir -p tests/tmp tmpbase=$troot/tmp tmp=tests/tmp/$testname @@ -152,7 +153,7 @@ t-reporefs () { exec >"$outputfile" if test -d $whichrepo; then cd $whichrepo - git show-ref |sort + git show-ref |t-sort fi) } @@ -1134,7 +1135,11 @@ t-alt-test () { t-git-config dgit.default.old-dsc-distro test-dummy -case "$0" in -*/gnupg) ;; -*) t-setup-import gnupg ;; -esac +for import in ${autoimport-gnupg}; do + case "$0" in + */$import) ;; + *) + t-setup-import $import + ;; + esac +done diff --git a/tests/lib-core b/tests/lib-core index c3a04cb..724c8ac 100644 --- a/tests/lib-core +++ b/tests/lib-core @@ -13,8 +13,10 @@ t-set-intree () { : ${DGIT_SSH_DISPATCH_TEST:=$DGIT_TEST_INTREE/infra/dgit-ssh-dispatch} : ${DGIT_INFRA_PFX:=$DGIT_TEST_INTREE${DGIT_TEST_INTREE:+/infra/}} : ${DGIT_GITDEBREBASE_TEST:=$DGIT_TEST_INTREE/git-debrebase} + : ${DGIT_MANPAGES_SOURCE_DIR:=$DGIT_TEST_INTREE} export DGIT_TEST DGIT_BADCOMMIT_FIXUP export DGIT_REPOS_SERVER_TEST DGIT_SSH_DISPATCH_TEST + export DGIT_MANPAGES_SOURCE_DIR export PERLLIB="$DGIT_TEST_INTREE${PERLLIB:+:}${PERLLIB}" } @@ -38,3 +40,7 @@ t-filter-out-git-hyphen-dir () { path="${path%:}" PATH="$path" } + +t-sort () { + LC_COLLATE=C sort "$@" +} diff --git a/tests/lib-gdr b/tests/lib-gdr index 7b4f085..22ea6d1 100644 --- a/tests/lib-gdr +++ b/tests/lib-gdr @@ -141,7 +141,7 @@ t-gdr-good () { test $cnparents = $enparents local cndparents=` - for f in $parents; do echo $f; done | sort -u | wc -w + for f in $parents; do echo $f; done | t-sort -u | wc -w ` test $cndparents = $cnparents diff --git a/tests/lib-import-chk b/tests/lib-import-chk index 88984c1..d6633f9 100644 --- a/tests/lib-import-chk +++ b/tests/lib-import-chk @@ -1,11 +1,11 @@ t-import-chk-authorship () { perl -ne 'print $1,"\n" if m/^ -- (\S.*\>) /' debian/changelog \ - | sort -u \ + | t-sort -u \ > $tmp/authorship.changelog ${import_chk_changelog_massage:-:} $tmp/authorship.changelog git log --pretty=format:'%an <%ae>%n%cn <%ce>' \ - | sort -u \ + | t-sort -u \ > $tmp/authorship.commits diff $tmp/authorship.{changelog,commits} } @@ -63,7 +63,7 @@ t-import-chk2() { t-ref-same refs/heads/first-2nd-import for orig in ../${p}_${v%-*}.orig*.tar.*; do - tar -atf $orig | LC_ALL=C sort >../files.o + tar -atf $orig | t-sort >../files.o pfx=$(perl <../files.o -ne ' while (<>) { m#^([^/]+/)# or exit 0; @@ -87,7 +87,7 @@ t-import-chk2() { t-ref-same-val "$orig $start" "$imp" done git ls-tree -r --name-only "$t_ref_val:" \ - | sort >../files.g + | t-sort >../files.g diff ../files.{o,g} done cd .. diff --git a/tests/setup/gdr-convert-gbp b/tests/setup/gdr-convert-gbp index 0b525c8..e523fd3 100755 --- a/tests/setup/gdr-convert-gbp +++ b/tests/setup/gdr-convert-gbp @@ -1,8 +1,11 @@ #!/bin/bash set -e +autoimport= . tests/lib . $troot/lib-gdr +$ifarchive t-setup-import gnupg + t-dependencies GDR t-tstunt-parsechangelog diff --git a/tests/setup/gdr-convert-gbp-noarchive b/tests/setup/gdr-convert-gbp-noarchive index dfeea3b..1d6758b 100755 --- a/tests/setup/gdr-convert-gbp-noarchive +++ b/tests/setup/gdr-convert-gbp-noarchive @@ -1,4 +1,5 @@ #!/bin/bash +autoimport= set -e . tests/lib . $troot/lib-gdr diff --git a/tests/setup/gnupg b/tests/setup/gnupg index c88d40b..7a164ef 100755 --- a/tests/setup/gnupg +++ b/tests/setup/gnupg @@ -7,10 +7,11 @@ cp $troot/gnupg/* $tmp/gnupg chmod go-rw $tmp/gnupg/* export DGIT_TEST_GNUPG_GLOBAL_LOCK=$tmp/gnupg/dgit-test-global-lock +export DGIT_TEST_GNUPG_LOG=$tmp/gnupg-workarounds.log setup=' export GNUPGHOME=$tmp/gnupg - export DGIT_TEST_GNUPG_GLOBAL_LOCK + export DGIT_TEST_GNUPG_GLOBAL_LOCK DGIT_TEST_GNUPG_LOG cat >$tmp/gnupg/gpg-agent.conf <<END log-file $tmp/gnupg/AGENT.log @@ -27,6 +28,7 @@ eval "$setup" gpg --list-secret -t-setup-done 'DGIT_TEST_GNUPG_GLOBAL_LOCK' 'gnupg' "$setup" +t-setup-done 'DGIT_TEST_GNUPG_GLOBAL_LOCK DGIT_TEST_GNUPG_LOG' \ + 'gnupg' "$setup" t-ok diff --git a/tests/tartree-edit b/tests/tartree-edit index 40bd6e9..78f0e4f 100755 --- a/tests/tartree-edit +++ b/tests/tartree-edit @@ -17,7 +17,7 @@ gitfetchdiff_list () { git for-each-ref --format '%(refname) %(objectname)' \ refs/remotes/"$1" \ | sed 's/^refs\/remotes\/[^\/]*\///' \ - | sort >"$play/$2" + | t-sort >"$play/$2" } gitfetchdiff () { diff --git a/tests/tests/checkout b/tests/tests/checkout new file mode 100755 index 0000000..756c49b --- /dev/null +++ b/tests/tests/checkout @@ -0,0 +1,59 @@ +#!/bin/bash +set -e +. tests/lib +t-tstunt-parsechangelog + +t-setup-import examplegit + +now-on () { + local branch=$(git symbolic-ref HEAD) + test "$branch" = "refs/heads/$1" +} + +p=example + +mkdir $p.2 +cd $p.2 + +git init +t-dgit setup-new-tree +t-dgit checkout -p $p unstable + +now-on dgit/sid +t-refs-same-start +t-ref-head +t-ref-same refs/tags/test-dummy/$v + +t-dgit checkout -p $p stable +now-on dgit/stable + +t-dgit checkout -d no-such-distro sid +t-ref-head +now-on dgit/sid + +t-dgit checkout stable +now-on dgit/stable + +git branch -D dgit/sid +t-dgit checkout -d no-such-distro sid +t-ref-head +now-on dgit/sid + +git reflog --pretty=tformat:%gs >../reflog.got +cat >../reflog.expect <<END +dgit checkout sid +dgit checkout stable +dgit checkout sid +dgit checkout stable +dgit checkout unstable +END +diff -u ../reflog.{expect,got} + +git for-each-ref --format='%(refname)' refs/heads | t-sort >../refs.got +cat >../refs.expect <<END +refs/heads/dgit/sid +refs/heads/dgit/stable +END +diff -u ../refs.{expect,got} + +t-ok diff --git a/tests/tests/gdr-makepatches7 b/tests/tests/gdr-makepatches7 index 9c39710..02ea7ab 100755 --- a/tests/tests/gdr-makepatches7 +++ b/tests/tests/gdr-makepatches7 @@ -8,6 +8,15 @@ t-setup-import gdr-convert-gbp cd $p +git checkout upstream/2.0 +echo '*patch*' >>.gitignore +git commit -m nasty .gitignore +git tag v2.1 +GZIP=-1 git archive -o ../${p}_2.1.orig.tar.gz --prefix ${p}/ v2.1 + +git checkout master +t-git-debrebase new-upstream 2.1-1 + t-some-changes for-rebase-fixup m t-git-debrebase diff --git a/tests/tests/gdr-newupstream b/tests/tests/gdr-newupstream index 536f49c..39ed24b 100755 --- a/tests/tests/gdr-newupstream +++ b/tests/tests/gdr-newupstream @@ -1,5 +1,6 @@ #!/bin/bash set -e +autoimport= . tests/lib t-dependencies NO-DGIT GDR @@ -35,8 +36,10 @@ t-git-debrebase new-upstream $v git tag v2.1 upstream -t-git-debrebase new-upstream $v +t-git-debrebase new-upstream ${v%-*} + t-gdr-good laundered +git reflog | egrep 'debrebase new-upstream.*checkout' t-git-debrebase stitch t-gdr-good stitched @@ -54,8 +57,11 @@ anchor=$(perl <../anal.anch -ne ' exit; ') +GIT_REFLOG_ACTION='STUNT-RLA' \ t-git-debrebase --anchor=$anchor -fanchor-treated new-upstream $v upstream t-gdr-good laundered +git reflog | egrep 'STUNT-RLA: debrebase new-upstream' +git reflog | egrep 'STUNT-RLA: debrebase: launder for new upstream' t-git-debrebase stitch t-gdr-good stitched diff --git a/tests/tests/gdr-viagit b/tests/tests/gdr-viagit index 644d2d4..a83e622 100755 --- a/tests/tests/gdr-viagit +++ b/tests/tests/gdr-viagit @@ -1,5 +1,6 @@ #!/bin/bash set -e +autoimport= . tests/lib t-dependencies NO-DGIT GDR diff --git a/tests/tests/import-native b/tests/tests/import-native index 1e09343..0766841 100755 --- a/tests/tests/import-native +++ b/tests/tests/import-native @@ -8,7 +8,7 @@ t-tstunt-parsechangelog mkdir $tmp/aside versions="" -for f in $(find $tmp/mirror -name \*.dsc | sort); do +for f in $(find $tmp/mirror -name \*.dsc | t-sort); do perl -i -pe ' $_="" if m/^-----BEGIN PGP SIGNED/..!m/\S/; $_="" if m/^-----BEGIN PGP SIGNATURE/..0; diff --git a/tests/tests/manpages-format b/tests/tests/manpages-format new file mode 100755 index 0000000..7ba2f9d --- /dev/null +++ b/tests/tests/manpages-format @@ -0,0 +1,78 @@ +#!/bin/bash +set -e +autoimport= +. tests/lib + +t-dependencies man-db make groff git-debrebase + +cd $root + +printenv |grep MAKE ||: |t-sort +manpages=$(MAKEFLAGS= MAKELEVEL= make list-manpages) + +export MANWIDTH=80 + +run_man () { + if [ "x${DGIT_MANPAGES_SOURCE_DIR}" = x ]; then + cmd='man "$@" $section $page' + else + make $roff >&2 + cmd='man "$@" -l $roff' + fi + eval "$cmd 2>&1 >/dev/null |tee $errs" +} + +for roff in $manpages; do + for fmt in txt ps; do + >$tmp/$roff.$fmt-expected + done +done + +expected () { + cat >$tmp/$2.$1-expected +} + +not_egrep_vxPf () { + # egrep -vxPf does not work, so we reimplement it + perl -ne ' + BEGIN () { + open PATS, shift @ARGV or die $!; + $re = join "|", map { chomp; qr{^(?:$_)$} } + qr{^(?=a)b}, <PATS>; + print STDERR "RE $re\n"; + } + next if m{$re}; + print STDERR "unexpected: $_"; + $bad = 1; + END { die "unexpected errors\n" if $bad; } + ' "$@" +} + +expected txt dgit.1 <<'END' +.* # table wider than line width +END + +prep () { + fmt=$1 + errs=$tmp/$roff.$fmt-errs +} + +check () { + perl -0777 -i~ -pe 's/\n[ \t]+/ # /' $errs + not_egrep_vxPf $tmp/$roff.$fmt-expected $errs +} + +for roff in $manpages; do + section=${roff##*.} + page=${roff%.*} + + prep txt + run_man + check + + prep ps + run_man -Tps + check +done + +t-ok diff --git a/tests/tests/overwrite-splitbrains b/tests/tests/overwrite-splitbrains index 0ef03f6..06d1a98 100755 --- a/tests/tests/overwrite-splitbrains +++ b/tests/tests/overwrite-splitbrains @@ -14,7 +14,7 @@ t-dgit fetch t-refs-same-start t-ref-head -t-expect-fail 'check failed (maybe --overwrite is needed' \ +t-expect-fail 'maybe --overwrite is needed' \ t-dgit --quilt=gbp --dgit-view-save=split.p push t-refs-same-start diff --git a/tests/tests/push-newrepeat b/tests/tests/push-newrepeat new file mode 100755 index 0000000..87fcb35 --- /dev/null +++ b/tests/tests/push-newrepeat @@ -0,0 +1,21 @@ +#!/bin/bash +set -e +. tests/lib + +t-tstunt-parsechangelog + +t-prep-newpackage example 1.0 + +cd $p +git checkout quilt-tip +cp $troot/pkg-srcs/${p}_1.0.orig.tar.gz .. + +t-dgit --quilt=smash build-source + +t-expect-fail E:'Push failed, while updating the remote git repository' \ +t-dgit -cdgit-distro.test-dummy.git-url=file:///dev/enoent/fail \ + push --new + +t-dgit push --new + +t-ok diff --git a/tests/tests/sourceonlypolicy b/tests/tests/sourceonlypolicy new file mode 100755 index 0000000..b0569c3 --- /dev/null +++ b/tests/tests/sourceonlypolicy @@ -0,0 +1,38 @@ +#!/bin/bash +set -e +. tests/lib + +t-tstunt-parsechangelog + +t-prep-newpackage example 1.0 + +cd $p +revision=1 + +dgit-with-policy () { + local policy=$1; shift + t-dgit -cdgit-distro.test-dummy.source-only-uploads=$policy "$@" +} + +t-expect-fail E:'source-only.*entirely NEW' \ +dgit-with-policy not-wholly-new push-source --new + +t-expect-fail E:'source-only.*requires \.debs' \ +dgit-with-policy never push-source --new + +dgit-with-policy always push-source --new + +t-archive-process-incoming sid + +t-commit 'Now with binaries' + +t-dgit -wgf build + +t-expect-fail E:'uploading binaries.*source only' \ +dgit-with-policy always push --new + +t-commit 'Source-only not NEW' + +dgit-with-policy not-wholly-new push-source --new + +t-ok diff --git a/tests/tests/trustingpolicy-replay b/tests/tests/trustingpolicy-replay index ad731f5..2a1012b 100755 --- a/tests/tests/trustingpolicy-replay +++ b/tests/tests/trustingpolicy-replay @@ -4,6 +4,8 @@ set -e t-tstunt-parsechangelog +t-dependencies dput-ng + t-git-config dgit.default.dep14tag no t-dsd @@ -17,11 +19,12 @@ git tag start t-dgit build t-dgit push --new +t-rm-dput-dropping + t-commit 'Prep v1.1 which will be rewound' t-dgit build t-dgit push -t-rm-dput-dropping git checkout $tagpfx/1.0 t-dgit build t-dgit push --deliberately-fresh-repo diff --git a/tests/tstunt/gpg b/tests/tstunt/gpg index 679a6b8..4214b4a 100755 --- a/tests/tstunt/gpg +++ b/tests/tstunt/gpg @@ -3,4 +3,20 @@ set -e exec \ with-lock-ex -w "$DGIT_TEST_GNUPG_GLOBAL_LOCK" \ - $tmp "$DGIT_TEST_TROOT"/tstunt/gpg-locked "$@" + sh -c ' + "$@" 9>&2 2>>"$DGIT_TEST_GNUPG_LOG" + rc=$? + if [ $rc = 0 ]; then exit 0; fi + if [ "x$DGIT_TEST_BYHAND" != x ]; then + echo >&2 "BYHAND, not dumping $DGIT_TEST_GNUPG_LOG" + else + echo >&2 "########################################" + echo >&2 "$DGIT_TEST_GNUPG_LOG" + sed '\''s/^/\[gnupg-workarounds] /'\'' >&2 \ + "$DGIT_TEST_GNUPG_LOG" + echo >&2 "end of $DGIT_TEST_GNUPG_LOG" + echo >&2 "########################################" + fi + exit $rc + ' x \ + "$DGIT_TEST_TROOT"/tstunt/gpg-withagent "$@" diff --git a/tests/tstunt/gpg-withagent b/tests/tstunt/gpg-withagent new file mode 100755 index 0000000..b7b8bfd --- /dev/null +++ b/tests/tstunt/gpg-withagent @@ -0,0 +1,68 @@ +#!/bin/sh +set -ex + +d () { + date --iso-8601=ns >&2 + ps -ef | grep gpg-agent >&2 ||: +} + +d + +retry_until_ok () { + sleeptime=0 + d + while ! "$@"; do + d + case $sleeptime in + ??.*) + echo >&2 "$0: GPG AGENT STARTP $@ TIMED OUT" + exit 127 + ;; + esac + sleep $sleeptime + sleeptime=$(echo "($sleeptime + 0.001) * 2" | bc -l) + done +} + +kill_agent_not_running () { + LC_MESSAGES=C gpg-connect-agent --no-autostart </dev/null \ + KILLAGENT /bye 2>&1 \ + | tee -a /dev/stderr \ + | grep 'no gpg-agent running' >&2 +} + +echo >&2 'GPG-WITHAGENT... PRE-STOPPING' + +retry_until_ok kill_agent_not_running + +agent_is_running () { + gpg-connect-agent --no-autostart </dev/null \ + '/echo dgit-gpg-agent-ok' /bye 2>&1 \ + | grep dgit-gpg-agent-ok >&2 +} + + +$DGIT_STUNT_AGENT --daemon </dev/null >&2 +retry_until_ok agent_is_running + +echo >&2 'GPG-WITHAGENT... RUNNING' + +d + +set +e +$DGIT_TEST_REAL_GPG \ + --agent-program=$DGIT_STUNT_AGENT "$@" 2>&9 +rc=$? +set -e + +d + +echo >&2 'GPG-WITHAGENT... STOPPING' + +retry_until_ok kill_agent_not_running + +echo >&2 'GPG-WITHAGENT... DONE' + +d + +exit $rc |