summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile13
-rw-r--r--tests/lib27
-rw-r--r--tests/lib-build-modes41
-rw-r--r--tests/lib-import-chk22
-rw-r--r--tests/lib-restricts2
-rwxr-xr-xtests/pretend-pbuilder26
-rwxr-xr-xtests/run-all13
-rwxr-xr-xtests/tests/build-modes-asplit5
-rwxr-xr-xtests/tests/build-modes-gbp1
-rwxr-xr-xtests/tests/build-modes-gbp-asplit5
-rwxr-xr-xtests/tests/build-modes-sbuild4
-rwxr-xr-xtests/tests/import-nonnative1
-rwxr-xr-xtests/tests/pbuilder42
-rwxr-xr-xtests/tests/push-source1
-rwxr-xr-xtests/tests/push-source-with-changes4
-rwxr-xr-xtests/tests/quilt-gbp-build-modes-sbuild2
-rwxr-xr-xtests/tests/quilt-splitbrains3
-rwxr-xr-xtests/tests/sbuild-gitish3
18 files changed, 162 insertions, 53 deletions
diff --git a/tests/Makefile b/tests/Makefile
index e6ce153..8494284 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -7,19 +7,12 @@ TESTSCRIPTS ?= $(shell tests/enumerate-tests)
TESTNAMES := $(notdir $(TESTSCRIPTS))
all: $(foreach t,$(TESTNAMES),tests/tmp/$t.ok)
- @echo "ALL PASSED"
-
-tests/tmp:
- mkdir -p $@
+ @echo "ALL PASSED$${DGIT_TESTS_PROGRESSIVE+ AT SOME POINT}"
+tests/tmp/%.ok:
ifeq ($(DGIT_TEST_RETRY_COUNT),)
-
-tests/tmp/%.ok: tests/tmp
tests/tests/$* >tests/tmp/$*.log 2>&1
-
else
-
-tests/tmp/%.ok: tests/tmp
@for retry in $$( seq 1 $(DGIT_TEST_RETRY_COUNT) ); do \
echo "[$$retry] $*"; \
tests/tests/$* >tests/tmp/$*.$$retry.log 2>&1; \
@@ -27,5 +20,5 @@ tests/tmp/%.ok: tests/tmp
if [ $$rc = 0 ]; then exit 0; fi; \
echo >&2 "[$$retry] $* TEST FAILED $$rc"; \
done; exit $$rc
-
endif
+ @touch $@
diff --git a/tests/lib b/tests/lib
index 99345ce..6028133 100644
--- a/tests/lib
+++ b/tests/lib
@@ -40,6 +40,7 @@ root=`pwd`
troot=$root/tests
testname="${DGIT_TEST_TESTNAME-${0##*/}}"
export DGIT_TEST_TROOT=$troot
+bpd=..
tmp=$ADTTMP
if [ x"$tmp" = x ]; then
@@ -64,6 +65,7 @@ env -0 >$tmp/.save-env
ln -f $troot/ssh ssh
export DEBCHANGE_VENDOR=dpkg
+unset VISUAL
mkdir -p $tmp/incoming
cat <<END >$tmp/dput.cf
@@ -73,6 +75,9 @@ incoming = $tmp/incoming
run_dinstall = 0
END
+schroot=${DGIT_SCHROOT_CHROOT:-build}
+# Pretty much any Debian sid snapshot schroot will do.
+
: ${t_archive_method:=aq}
: ${tagpfx:=archive/test-dummy}
: ${suitespecs:=sid:unstable}
@@ -670,6 +675,12 @@ t-push-was-source-only () {
done
}
+t-push-included () {
+ for f in $@; do
+ stat $tmp/incoming/$f
+ done
+}
+
t-pushed-good () {
local branch=$1
local suite=${2:-sid}
@@ -697,6 +708,12 @@ t-pushed-good-core () {
git verify-tag `t-v-tag`
}
+t-pushed-good-check-changes () {
+ changes_filename="$tmp/incoming/${p}_${v}_*.changes"
+ grep -E "^Distribution: $suite" $changes_filename
+ grep -E "^Version: $v" $changes_filename
+}
+
t-splitbrain-pushed-good--unpack () {
cd $tmp
rm -rf t-unpack
@@ -1129,6 +1146,16 @@ t-policy-periodic () {
: '))))))))))))))))))))))))))))))))))))))))'
}
+t-buildproductsdir-config () {
+ bpd=$tmp/bpd
+ t-git-config dgit.default.build-products-dir $bpd
+ mkdir -p $bpd
+ cat <<END >>$tmp/.gbp.conf
+[buildpackage]
+export-dir = $bpd
+END
+}
+
t-restrict () {
local restriction=$1
(cd $root; t-restriction-$restriction >&2)
diff --git a/tests/lib-build-modes b/tests/lib-build-modes
index ee2975d..3bb1bf3 100644
--- a/tests/lib-build-modes
+++ b/tests/lib-build-modes
@@ -87,7 +87,7 @@ bm-quirk-sbuild-after-act () {
# provide sbuild with the dsc, not the tree, so we simply
# ignore all executions of the clean target by schroot.
local arch; arch=$(dpkg-architecture -qDEB_BUILD_ARCH)
- local sblog=../example_${v}_$arch.build
+ local sblog=$bpd/example_${v}_$arch.build
if [ -e $sblog ]; then
sed '
s/^EXAMPLE RULES TARGET clean/HOOK SUPPRESSED &/;
@@ -120,7 +120,31 @@ bm-compute-expected () {
exec 4>$bmexp
echo >&4 "$heading"
- case $cleanmode in
+ local eff_cleanmode=$cleanmode
+
+ case "$e_targets" in
+ *[^\ ]*)
+ ;;
+ *)
+ # dgit won't bother cleaning the tree
+ # if no build is going to be run
+ eff_cleanmode=none
+ ;;
+ esac
+
+ case "$act" in
+ sbuild*)
+ # dgit sbuild won't bother cleaning the tree
+ # because it doesn't need to to make a .dsc for sbuild
+ eff_cleanmode=none
+ ;;
+ esac
+
+ # we are running the builder in-tree ?
+ # when we have --include-dirty, we will want to check
+ # that too and reset eff_cleanmode to $cleanmode
+
+ case $eff_cleanmode in
git) echo >&4 'BUILD-MODES PROGRAM git clean -xdf' ;;
git-ff) echo >&4 'BUILD-MODES PROGRAM git clean -xdff' ;;
check) echo >&4 'BUILD-MODES PROGRAM git clean -xdn' ;;
@@ -155,7 +179,7 @@ bm-run-one () {
bmid="$act,$cleanmode,$branch"
bmid=${bmid// /_}
- rm -f ../${p}_{v}_*.changes
+ rm -f $bpd/${p}_{v}_*.changes
heading="===== [$bmid] dgit $args ====="
@@ -168,7 +192,7 @@ bm-run-one () {
git checkout $branch
git clean -xdf # since we might not do any actual cleaning
- dsc="../example_$v.dsc"
+ dsc="$bpd/example_$v.dsc"
rm -f $dsc
set +o pipefail
@@ -199,7 +223,7 @@ bm-run-one () {
bm-report-test "SOURCE FILE" [ -e $dsc ]
if [ $actual_status = success ]; then
- local changes; changes=$(echo ../example_${v}_*.changes)
+ local changes; changes=$(echo $bpd/example_${v}_*.changes)
case "$changes" in
*' '*) fail "build generated ambiguous .changes: $changes" ;;
esac
@@ -226,10 +250,3 @@ bm-act-iterate () {
done
: bm-act-iterate done.
}
-
-bm-alwayssplit () {
- local t=${0##*/}
- DGIT_TEST_BM_BASEARGS+=' --always-split-source-build'
- export DGIT_TEST_BM_BASEARGS
- t-chain-test "${t%%-asplit}"
-}
diff --git a/tests/lib-import-chk b/tests/lib-import-chk
index d6633f9..e18f66e 100644
--- a/tests/lib-import-chk
+++ b/tests/lib-import-chk
@@ -45,7 +45,7 @@ t-import-chk2() {
# The resulting .dsc does not have a Dgit line (because dgit push
# puts that in). So we just shove it in the archive now
- ln ../${p}_${v}.* $tmp/mirror/pool/main/
+ ln $bpd/${p}_${v}.* $tmp/mirror/pool/main/
t-archive-query
t-dgit fetch
@@ -62,9 +62,9 @@ t-import-chk2() {
t-ref-same refs/remotes/dgit/dgit/sid
t-ref-same refs/heads/first-2nd-import
- for orig in ../${p}_${v%-*}.orig*.tar.*; do
- tar -atf $orig | t-sort >../files.o
- pfx=$(perl <../files.o -ne '
+ for orig in $bpd/${p}_${v%-*}.orig*.tar.*; do
+ tar -atf $orig | t-sort >$bpd/files.o
+ pfx=$(perl <$bpd/files.o -ne '
while (<>) {
m#^([^/]+/)# or exit 0;
$x //= $1;
@@ -75,20 +75,20 @@ t-import-chk2() {
perl -i~ -pe '
s#^\Q'"$pfx"'\E##;
$_="" if m/^$/ || m#/$# || m#^\.git/#;
- ' ../files.o
- orig=${orig#../}
+ ' $bpd/files.o
+ orig=${orig#$bpd/}
pat="^Import ${orig//./\\.}\$"
t-refs-same-start
for start in first-import first-2nd-import; do
git log --pretty='tformat:%H' --grep "$pat" $start \
- >../t.imp
- test $(wc -l <../t.imp) = 1
- imp=$(cat ../t.imp)
+ >$bpd/t.imp
+ test $(wc -l <$bpd/t.imp) = 1
+ imp=$(cat $bpd/t.imp)
t-ref-same-val "$orig $start" "$imp"
done
git ls-tree -r --name-only "$t_ref_val:" \
- | t-sort >../files.g
- diff ../files.{o,g}
+ | t-sort >$bpd/files.g
+ diff $bpd/files.{o,g}
done
cd ..
}
diff --git a/tests/lib-restricts b/tests/lib-restricts
index bb695c4..dfaaa25 100644
--- a/tests/lib-restricts
+++ b/tests/lib-restricts
@@ -13,6 +13,8 @@ t-restriction-x-dgit-git-only () {
}
t-restriction-x-dgit-schroot-build () {
+ # if DGIT_SCHROOT_CHROOT is set, user wants not to skip this test
+ if [ "x${DGIT_SCHROOT_CHROOT}" != x ]; then return 0; fi
schroot -l -c build 2>&1 >/dev/null || return 1
}
diff --git a/tests/pretend-pbuilder b/tests/pretend-pbuilder
new file mode 100755
index 0000000..8495a2f
--- /dev/null
+++ b/tests/pretend-pbuilder
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+
+my $operation = shift;
+die "pbuilder: you should use me only to build, dgit"
+ unless ($operation eq "build" || $operation eq "b");
+
+my $debbuildopts = undef;
+my $distribution = undef;
+GetOptions('debbuildopts=s' => \$debbuildopts,
+ 'distribution=s' => \$distribution);
+
+# ignore user args; last argument has to be the .dsc filename
+my $dsc = $ARGV[-1];
+die "pbuilder: last argument has wrong file extension"
+ unless ($dsc =~ m/^(.*)_.*\.dsc$/);
+
+system "dpkg-source -x $dsc pbuilder";
+chdir 'pbuilder';
+system <<END
+dpkg-buildpackage --changes-option=-DDistribution=$distribution $debbuildopts
+END
diff --git a/tests/run-all b/tests/run-all
index f72b9fa..c930171 100755
--- a/tests/run-all
+++ b/tests/run-all
@@ -1,10 +1,19 @@
#!/bin/bash
set -e
# convenience script for running the tests outside adt-run
-# usage: tests/using-intree tests/run-all
+# usage: tests/using-intree tests/run-all [-p|--progressive] [tests/tests/*]
set -o pipefail
+while [ $# != 0 ]; do
+ case "$1" in
+ --progressive|-p) shift; export DGIT_TESTS_PROGRESSIVE=y;;
+ --) shift; break ;;
+ -*) echo >&2 "run-all: unknown option $1"; exit 20 ;;
+ *) break ;;
+ esac
+done
+
ncpus=$(nproc || echo 1)
jcpus=-j$(( ncpus * 134 / 100 ))
@@ -14,6 +23,8 @@ fi
mkdir -p tests/tmp
+${DGIT_TESTS_PROGRESSIVE+:} rm -f tests/tmp/*.ok
+
export DGIT_GNUPG_STUNT_ERRLOG=$( tty -s ||: )
(
diff --git a/tests/tests/build-modes-asplit b/tests/tests/build-modes-asplit
deleted file mode 100755
index fa3bf8a..0000000
--- a/tests/tests/build-modes-asplit
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-set -e
-. tests/lib
-. $troot/lib-build-modes
-bm-alwayssplit
diff --git a/tests/tests/build-modes-gbp b/tests/tests/build-modes-gbp
index 50a6288..d99b791 100755
--- a/tests/tests/build-modes-gbp
+++ b/tests/tests/build-modes-gbp
@@ -4,6 +4,7 @@ set -e
. $troot/lib-build-modes
t-dependencies git-buildpackage
+t-buildproductsdir-config
quirk-clean-fixup () {
case $cleanmode in
diff --git a/tests/tests/build-modes-gbp-asplit b/tests/tests/build-modes-gbp-asplit
deleted file mode 100755
index fa3bf8a..0000000
--- a/tests/tests/build-modes-gbp-asplit
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-set -e
-. tests/lib
-. $troot/lib-build-modes
-bm-alwayssplit
diff --git a/tests/tests/build-modes-sbuild b/tests/tests/build-modes-sbuild
index 19dcc8a..be2d4c9 100755
--- a/tests/tests/build-modes-sbuild
+++ b/tests/tests/build-modes-sbuild
@@ -6,10 +6,12 @@ set -e
t-dependencies sbuild
t-restrict x-dgit-schroot-build
+t-buildproductsdir-config
+
bm_quirk_after_act=bm-quirk-sbuild-after-act
bm-prep
-act="sbuild -c build --no-arch-all"
+act="sbuild -c $schroot --no-arch-all"
real_act="$act"
bm-guess-e-source-e-targets "$act"
diff --git a/tests/tests/import-nonnative b/tests/tests/import-nonnative
index 3568563..7bb33a9 100755
--- a/tests/tests/import-nonnative
+++ b/tests/tests/import-nonnative
@@ -4,6 +4,7 @@ set -e
. $troot/lib-import-chk
t-tstunt-parsechangelog
+t-buildproductsdir-config
# 1.0 with diff
t-import-chk pari-extra 3-1
diff --git a/tests/tests/pbuilder b/tests/tests/pbuilder
new file mode 100755
index 0000000..2c9dbae
--- /dev/null
+++ b/tests/tests/pbuilder
@@ -0,0 +1,42 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+suitespecs+=' stable'
+
+t-buildproductsdir-config
+
+t-prep-newpackage example 1.0
+
+cd $p
+
+t-commit "make a commit" 1.1 stable
+
+t-tstunt pbuilder
+
+t-expect-fail "dgit: error: you asked for a builder but your debbuildopts didn't ask for any binaries -- is this really what you meant?" \
+t-dgit -v0 --pbuilder="$troot/pretend-pbuilder" pbuilder -S
+
+t-expect-fail "dgit: error: we must build a .dsc to pass to the builder but your debbuiltopts forbids the building of a source package; cannot continue" \
+t-dgit -v0 --pbuilder="$troot/pretend-pbuilder" pbuilder -b
+
+# it would be nice to try passing -g on the end of the following line
+# to confirm it gets massaged into -A, but the example package is
+# RC-buggy in that it doesn't build with -A ..
+t-dgit -v0 --pbuilder="$troot/pretend-pbuilder" pbuilder
+
+t-dgit -wgf push --new
+
+t-pushed-good master stable
+t-pushed-good-check-changes
+
+# check we actually built binaries
+t-push-included example_1.1_all.deb
+
+# this purpose of this is to check that the _source.changes that was
+# merged is the one that dgit made, not something pbuilder made (this
+# works because the -v$v in the above is handled by dgit and not
+# passed on to pbuilder)
+grep -F "example (1.0)" $changes_filename
+
+t-ok
diff --git a/tests/tests/push-source b/tests/tests/push-source
index 9d132e5..f0eafb8 100755
--- a/tests/tests/push-source
+++ b/tests/tests/push-source
@@ -3,6 +3,7 @@ set -e
. tests/lib
t-tstunt-parsechangelog
+t-buildproductsdir-config
t-prep-newpackage example 1.0
diff --git a/tests/tests/push-source-with-changes b/tests/tests/push-source-with-changes
index b9a3906..580ea3a 100755
--- a/tests/tests/push-source-with-changes
+++ b/tests/tests/push-source-with-changes
@@ -2,8 +2,6 @@
set -e
. tests/lib
-arch=$(dpkg-architecture -qDEB_BUILD_ARCH)
-
t-tstunt-parsechangelog
t-prep-newpackage example 1.0
@@ -18,7 +16,7 @@ t-ref-head
t-dgit --dpkg-buildpackage:-d build -F
t-expect-push-fail 'user-specified changes file is not source-only' \
-t-dgit -C ../${p}_1.0_${arch}.changes push-source --new
+t-dgit -C ../${p}_1.0_multi.changes push-source --new
# (2) try pushing a source-only changes file
diff --git a/tests/tests/quilt-gbp-build-modes-sbuild b/tests/tests/quilt-gbp-build-modes-sbuild
index 4c86bfe..ec1d1c7 100755
--- a/tests/tests/quilt-gbp-build-modes-sbuild
+++ b/tests/tests/quilt-gbp-build-modes-sbuild
@@ -7,6 +7,6 @@ t-dependencies sbuild
t-restrict x-dgit-schroot-build
bm-gbp-example-acts \
- 'sbuild -c build --arch-all' \
+ "sbuild -c $schroot --arch-all" \
t-ok
diff --git a/tests/tests/quilt-splitbrains b/tests/tests/quilt-splitbrains
index 9f0ae5f..6886cf8 100755
--- a/tests/tests/quilt-splitbrains
+++ b/tests/tests/quilt-splitbrains
@@ -35,9 +35,6 @@ want-success () {
echo "===== testing tree suitable for --quilt=gbp (only) ====="
-t-expect-fail 'grep: new-upstream-file: No such file or directory' \
-t-dgit --quilt=dpm build-source
-
t-expect-fail 'git tree differs from result of applying' \
t-dgit -wgf --quilt=dpm build-source
diff --git a/tests/tests/sbuild-gitish b/tests/tests/sbuild-gitish
index 6e497b2..7c0a30c 100755
--- a/tests/tests/sbuild-gitish
+++ b/tests/tests/sbuild-gitish
@@ -6,6 +6,7 @@ t-dependencies sbuild man-db
t-restrict x-dgit-schroot-build
t-tstunt-parsechangelog
+t-buildproductsdir-config
t-prep-newpackage example 1.1
@@ -16,7 +17,7 @@ buildrune=$(
next unless m/^ +\%/ .. 0;
next if !m/\S/ .. 0;
s/^ +\%//;
- $fixchr += s/(\s-c\s*)jessie(\s|$)/$1build$2/;
+ $fixchr += s/(\s-c\s*)jessie(\s|$)/$1'"$schroot"'$2/;
print or die $!;
END { $fixchr == 1 or die $fixchr; }
'