chiark / gitweb /
Test suite: Break out bm-prep-ownpackage-branches
[dgit.git] / tests / lib-build-modes
index 836d1ecef921e6c8e2ac30fa146691812fb3575f..c3d636781ae0b33e7135e9a52a7f328c3a1d2ec2 100644 (file)
@@ -1,4 +1,17 @@
 
+bm-prep-ownpackage-branches () {
+       cat <<'END' >$tmp/stunt-git
+#!/bin/sh -e
+case "$*" in
+*clean*) echo >&2 "BUILD-MODES PROGRAM git $*" ;;
+esac
+exec git "$@"
+END
+       chmod +x $tmp/stunt-git
+
+       bm_branches="$1"
+}
+
 bm-prep () {
        t-tstunt-parsechangelog
 
@@ -11,16 +24,7 @@ bm-prep () {
                -i debian/control
        git commit -a -m bad-build-deps
 
-       cat <<'END' >$tmp/stunt-git
-#!/bin/sh -e
-case "$*" in
-*clean*) echo >&2 "BUILD-MODES PROGRAM git $*" ;;
-esac
-exec git "$@"
-END
-       chmod +x $tmp/stunt-git
-
-       counter=0
+       bm-prep-ownpackage-branches 'indep-arch bad-build-deps'
 
        if zgrep 'dpkg-buildpackage: Make dependency checks fatal for -S' \
                /usr/share/doc/dpkg-dev/changelog.gz; then
@@ -28,6 +32,10 @@ END
        else
                        dpkgbuildpackage_deps_for_clean=false
        fi
+
+       cleanmodes_default="git none dpkg-source dpkg-source-d"
+       cleanmodes_all="$cleanmodes_default git-ff check"
+       cleanmodes="$cleanmodes_default"
 }
 
 bm-guess-e-source-e-targets () {
@@ -38,6 +46,8 @@ bm-guess-e-source-e-targets () {
        *" -A") e_source=false; e_targets='build-indep binary-indep'    ;;
        *" -S") e_source=true;  e_targets=' '                           ;;
        *" -F") e_source=true;  e_targets='build binary'                ;;
+       *" -G") e_source=true;  e_targets='build-arch binary-arch'      ;;
+       *" -g") e_source=true;  e_targets='build-indep binary-indep'    ;;
        *)      e_source=true;  e_targets='build binary'                ;;
        esac
 }
@@ -53,8 +63,8 @@ bm-report-source () {
 
 bm-build-deps-ok () {
        case "$branch" in
-       indep-arch)             return 0        ;;
-       bad-build-deps)         return 1        ;;
+       *bad-build-deps*)       return 1        ;;
+       *)                      return 0        ;;
        esac
 }
 
@@ -93,23 +103,27 @@ bm-compute-expected () {
 }
 
 bm-run-one () {
-       local args="--clean=$cleanmode $real_act"
+       local args="$DGIT_TEST_BM_BASEARGS --clean=$cleanmode $real_act"
+
+       bmid="$act,$cleanmode,$branch"
+       bmid=${bmid// /_}
 
-       heading="===== [$counter $branch $cleanmode $act] dgit $args ====="
+       heading="===== [$bmid] dgit $args ====="
 
-       bmlog=$tmp/run-$counter-output
-       bmexp=$tmp/run-$counter-expected
-       bmgot=$tmp/run-$counter-results
+       bmlog=$tmp/run.$bmid.output
+       bmexp=$tmp/run.$bmid.expected
+       bmgot=$tmp/run.$bmid.results
 
        bm-compute-expected
 
        git checkout $branch
+       git clean -xdf # since we might not do any actual cleaning
 
        dsc='../example_1.0.dsc'
        rm -f $dsc
 
        set +o pipefail
-       t-dgit --git=$tmp/stunt-git $args 2>&1 | tee $bmlog
+       t-dgit --rm-old-changes --git=$tmp/stunt-git $args 2>&1 | tee $bmlog
        local ps="${PIPESTATUS[*]}"
        set -o pipefail
 
@@ -140,16 +154,20 @@ bm-run-one () {
        $bm_quirk_before_diff
 
        [ $actual_status = failure ] || diff -U10 $bmexp $bmgot
-
-       counter=$(( $counter + 1 ))
 }
 
 bm-act-iterate () {
-       for cleanmode in git none dpkg-source dpkg-source-d; do
-       # git-ff check removed because they're really very similar
-               for branch in indep-arch bad-build-deps; do
+       for cleanmode in $cleanmodes; do
+               for branch in $bm_branches; do
                        bm-run-one
                done
        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}"
+}