2 bm-prep-ownpackage-branches () {
3 cat <<'END' >$tmp/stunt-git
6 *clean*) echo >&2 "BUILD-MODES PROGRAM git $*" ;;
10 chmod +x $tmp/stunt-git
16 t-tstunt-parsechangelog
18 t-prep-newpackage example 1.0
22 git checkout -b bad-build-deps indep-arch
23 perl -pe 's/Build-Depends.*/$&, x-dgit-no-such-package/' \
25 git commit -a -m bad-build-deps
27 bm-prep-ownpackage-branches 'indep-arch bad-build-deps'
29 if zgrep 'dpkg-buildpackage: Make dependency checks fatal for -S' \
30 /usr/share/doc/dpkg-dev/changelog.gz; then
31 dpkgbuildpackage_deps_for_clean=true
33 dpkgbuildpackage_deps_for_clean=false
36 cleanmodes_default="git none dpkg-source dpkg-source-d"
37 cleanmodes_all="$cleanmodes_default git-ff check"
38 cleanmodes="$cleanmodes_default"
41 bm-gbp-example-acts () {
44 git checkout -b for-build-modes qc/quilt-tip-2
45 # build-modes cannot cope with branches containing /
47 bm-prep-ownpackage-branches for-build-modes
49 cleanmodes='git dpkg-source'
52 bm-guess-e-source-e-targets "$act"
53 real_act="--quilt=gbp $act"
55 sbuild*) bm_quirk_after_act=bm-quirk-sbuild-after-act ;;
56 gbp-*) real_act="$real_act --git-ignore-branch" ;;
57 *) bm_quirk_after_act='' ;;
63 bm-guess-e-source-e-targets () {
66 sbuild*" --no-arch-all"*)
67 e_source=true; e_targets='build-arch binary-arch' ;;
69 e_source=true; e_targets='' ;;
70 *" -b") e_source=false; e_targets='build binary' ;;
71 *" -B") e_source=false; e_targets='build-arch binary-arch' ;;
72 *" -A") e_source=false; e_targets='build-indep binary-indep' ;;
73 *" -S") e_source=true; e_targets=' ' ;;
74 *" -F") e_source=true; e_targets='build binary' ;;
75 *" -G") e_source=true; e_targets='build-arch binary-arch' ;;
76 *" -g") e_source=true; e_targets='build-indep binary-indep' ;;
77 *) e_source=true; e_targets='build binary' ;;
81 bm-quirk-sbuild-after-act () {
82 # sbuild likes to run the package clean target in the chroot,
83 # which isn't necessary in our case. We don't disable it in
84 # dgit because we want to do what sbuild does, in case there
85 # are packages which don't build unless their clean target was
86 # run. We know it must be running it in the chroot because we
87 # provide sbuild with the dsc, not the tree, so we simply
88 # ignore all executions of the clean target by schroot.
89 local arch=$(dpkg-architecture -qDEB_BUILD_ARCH)
90 local sblog=../example_${v}_$arch.build
91 if [ -e $sblog ]; then
93 s/^EXAMPLE RULES TARGET clean/HOOK SUPPRESSED &/;
96 echo "SBUILD LOG FILE ($sblog) MISSING"
100 bm-report-source () {
102 echo >&4 "SOURCE EXISTS"
104 echo >&4 "SOURCE MISSING"
108 bm-build-deps-ok () {
110 *bad-build-deps*) return 1 ;;
115 bm-compute-expected () {
116 require_fail=unexpect # or required
117 tolerate_fail=unexpect # or tolerate
123 git) echo >&4 'BUILD-MODES PROGRAM git clean -xdf' ;;
124 git-ff) echo >&4 'BUILD-MODES PROGRAM git clean -xdff' ;;
125 check) echo >&4 'BUILD-MODES PROGRAM git clean -xdn' ;;
126 dpkg-source-d) echo >&4 "EXAMPLE RULES TARGET clean" ;;
127 dpkg-source) bm-build-deps-ok || tolerate_fail=tolerate
128 echo >&4 "EXAMPLE RULES TARGET clean"
131 *) fail "t-compute-expected-run $cleanmode ??" ;;
134 if [ "x$e_targets" != x ]; then
135 # e_targets can be " " to mean `/may/ fail due to b-d'
136 bm-build-deps-ok || tolerate_fail=tolerate
139 for t in $e_targets; do
140 bm-build-deps-ok || require_fail=required
141 echo >&4 "EXAMPLE RULES TARGET $t"
144 bm-report-source $e_source
150 local args="$DGIT_TEST_BM_BASEARGS --clean=$cleanmode $real_act"
152 bmid="$act,$cleanmode,$branch"
155 heading="===== [$bmid] dgit $args ====="
157 bmlog=$tmp/run.$bmid.output
158 bmexp=$tmp/run.$bmid.expected
159 bmgot=$tmp/run.$bmid.results
164 git clean -xdf # since we might not do any actual cleaning
166 dsc="../example_$v.dsc"
170 t-dgit --rm-old-changes --git=$tmp/stunt-git $args 2>&1 | tee $bmlog
171 local ps="${PIPESTATUS[*]}"
180 "0 0") actual_status=success ;;
181 *" 0") actual_status=failure; echo >&4 "OPERATION FAILED"; ;;
182 *) fail "tee failed" ;;
185 case "$require_fail-$tolerate_fail-$actual_status" in
186 required-********-failure) echo >>$bmexp "REQUIRED FAILURE" ;;
187 ********-tolerate-failure) echo >>$bmexp "TOLERATED FAILURE" ;;
188 unexpect-********-success) ;;
189 *) fail "RF=$require_fail TF=$tolerate_fail AS=$actual_status" ;;
192 egrep >&4 '^EXAMPLE RULES TARGET|^BUILD-MODES' $bmlog || [ $? = 1 ]
194 bm-report-source [ -e $dsc ]
198 $bm_quirk_before_diff
200 [ $actual_status = failure ] || diff -U10 $bmexp $bmgot
204 for cleanmode in $cleanmodes; do
205 for branch in $bm_branches; do
209 : bm-act-iterate done.
214 DGIT_TEST_BM_BASEARGS+=' --always-split-source-build'
215 export DGIT_TEST_BM_BASEARGS
216 t-chain-test "${t%%-asplit}"