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
19 t-prep-newpackage example 1.0
23 git checkout -b bad-build-deps indep-arch
24 perl -pe 's/Build-Depends.*/$&, x-dgit-no-such-package/' \
26 git commit -a -m bad-build-deps
28 bm-prep-ownpackage-branches 'indep-arch bad-build-deps'
30 if zgrep 'dpkg-buildpackage: Make dependency checks fatal for -S' \
31 /usr/share/doc/dpkg-dev/changelog.gz; then
32 dpkgbuildpackage_deps_for_clean=true
34 dpkgbuildpackage_deps_for_clean=false
37 cleanmodes_default="git none dpkg-source dpkg-source-d"
38 cleanmodes_all="$cleanmodes_default git-ff check"
39 cleanmodes="$cleanmodes_default"
42 bm-gbp-example-acts () {
45 git checkout -b for-build-modes qc/quilt-tip-2
46 # build-modes cannot cope with branches containing /
48 bm-prep-ownpackage-branches for-build-modes
50 cleanmodes='git dpkg-source'
53 bm-guess-e-source-e-targets "$act"
54 real_act="--quilt=gbp $act"
56 sbuild*) bm_quirk_after_act=bm-quirk-sbuild-after-act ;;
57 gbp-*) real_act="$real_act --git-ignore-branch" ;;
58 *) bm_quirk_after_act='' ;;
64 bm-guess-e-source-e-targets () {
67 sbuild*" --no-arch-all"*)
68 e_source=true; e_targets='build-arch binary-arch' ;;
70 e_source=true; e_targets='' ;;
71 *" -b") e_source=false; e_targets='build binary' ;;
72 *" -B") e_source=false; e_targets='build-arch binary-arch' ;;
73 *" -A") e_source=false; e_targets='build-indep binary-indep' ;;
74 *" -S") e_source=true; e_targets=' ' ;;
75 *" -F") e_source=true; e_targets='build binary' ;;
76 *" -G") e_source=true; e_targets='build-arch binary-arch' ;;
77 *" -g") e_source=true; e_targets='build-indep binary-indep' ;;
78 *) e_source=true; e_targets='build binary' ;;
82 bm-quirk-sbuild-after-act () {
83 # sbuild likes to run the package clean target in the chroot,
84 # which isn't necessary in our case. We don't disable it in
85 # dgit because we want to do what sbuild does, in case there
86 # are packages which don't build unless their clean target was
87 # run. We know it must be running it in the chroot because we
88 # provide sbuild with the dsc, not the tree, so we simply
89 # ignore all executions of the clean target by schroot.
90 local arch; arch=$(dpkg-architecture -qDEB_BUILD_ARCH)
91 local sblog=$bpd/example_${v}_$arch.build
92 if [ -e $sblog ]; then
94 s/^EXAMPLE RULES TARGET clean/HOOK SUPPRESSED &/;
97 echo "SBUILD LOG FILE ($sblog) MISSING"
104 echo >&4 "$desc EXISTS"
106 echo >&4 "$desc MISSING"
110 bm-build-deps-ok () {
112 *bad-build-deps*) return 1 ;;
117 bm-compute-expected () {
118 require_fail=unexpect # or required
119 tolerate_fail=unexpect # or tolerate
124 local eff_cleanmode=$cleanmode
130 # if no build is going to be run, dgit will only check
131 # cleanliness rather than actually cleaning
132 eff_cleanmode=C$cleanmode
138 # dgit sbuild will only check cleanliness
139 # because it doesn't need to to make a .dsc for sbuild
140 eff_cleanmode=C$cleanmode
144 # we are running the builder in-tree ?
145 # when we have --include-dirty, we will want to check
146 # that too and reset eff_cleanmode to $cleanmode
148 case $eff_cleanmode in
149 git) echo >&4 'BUILD-MODES PROGRAM git clean -xdf' ;;
150 git-ff) echo >&4 'BUILD-MODES PROGRAM git clean -xdff' ;;
151 check|Ccheck) echo >&4 'BUILD-MODES PROGRAM git clean -dn -x' ;;
152 dpkg-source-d) echo >&4 "EXAMPLE RULES TARGET clean" ;;
153 dpkg-source) bm-build-deps-ok || tolerate_fail=tolerate
154 echo >&4 "EXAMPLE RULES TARGET clean"
157 C*) echo "TODO bm eff_cleanmode=$eff_cleanmode" ;;
158 *) fail "t-compute-expected-run $cleanmode ??" ;;
161 if [ "x$e_targets" != x ]; then
162 # e_targets can be " " to mean `/may/ fail due to b-d'
163 bm-build-deps-ok || tolerate_fail=tolerate
166 for t in $e_targets; do
167 bm-build-deps-ok || require_fail=required
168 echo >&4 "EXAMPLE RULES TARGET $t"
171 bm-report-test "SOURCE FILE" $e_source
172 bm-report-test "SOURCE IN CHANGES" $e_source
173 bm-report-test "DEBS IN CHANGES" expr "$e_targets" : '.*binary.*'
179 local args="$DGIT_TEST_BM_BASEARGS --clean=$cleanmode $real_act"
181 bmid="$act,$cleanmode,$branch"
184 rm -f $bpd/${p}_{v}_*.changes
186 heading="===== [$bmid] dgit $args ====="
188 bmlog=$tmp/run.$bmid.output
189 bmexp=$tmp/run.$bmid.expected
190 bmgot=$tmp/run.$bmid.results
195 git clean -xdf # since we might not do any actual cleaning
197 dsc="$bpd/example_$v.dsc"
201 t-dgit --rm-old-changes --git=$tmp/stunt-git $args 2>&1 | tee $bmlog
202 local ps="${PIPESTATUS[*]}"
211 "0 0") actual_status=success ;;
212 *" 0") actual_status=failure; echo >&4 "OPERATION FAILED"; ;;
213 *) fail "tee failed" ;;
216 case "$require_fail-$tolerate_fail-$actual_status" in
217 required-********-failure) echo >>$bmexp "REQUIRED FAILURE" ;;
218 ********-tolerate-failure) echo >>$bmexp "TOLERATED FAILURE" ;;
219 unexpect-********-success) ;;
220 *) fail "RF=$require_fail TF=$tolerate_fail AS=$actual_status" ;;
223 egrep >&4 '^EXAMPLE RULES TARGET|^BUILD-MODES' $bmlog || [ $? = 1 ]
225 bm-report-test "SOURCE FILE" [ -e $dsc ]
227 if [ $actual_status = success ]; then
228 local changes; changes=$(echo $bpd/example_${v}_*.changes)
230 *' '*) fail "build generated ambiguous .changes: $changes" ;;
233 perl -ne 'print if m/^files:/i ... m/^\S/' \
234 <$changes >$changes.files
236 bm-report-test "SOURCE IN CHANGES" grep '\.dsc$' $changes.files
237 bm-report-test "DEBS IN CHANGES" grep '\.deb$' $changes.files
242 $bm_quirk_before_diff
244 [ $actual_status = failure ] || diff -U10 $bmexp $bmgot
248 for cleanmode in $cleanmodes; do
249 for branch in $bm_branches; do
253 : bm-act-iterate done.
256 bm-buildproductsdir-nonworking () {
257 t-git-config dgit.default.build-products-dir ../bpd-dummy