chiark / gitweb /
test suite: gdr-unprocessable: new test
[dgit.git] / tests / lib-gdr
1 #
2
3 : ${GDR_TEST_DEBUG=-D}
4 export GDR_TEST_DEBUG
5
6 t-git-debrebase () {
7         local gdr=${DGIT_GITDEBREBASE_TEST-git-debrebase}
8         : '
9 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
10         $gdr    $GDR_TEST_OPTS $GDR_TEST_DEBUG $t_gdr_xopts "$@"
11         : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
12 '
13 }
14
15 t-gdr-good () {
16         local state=$1
17         local beforetag=$2 # say HEAD to skip this check
18         # state should be one of
19         #   laundered
20         #   stitched
21         #   pushed
22
23         git diff --quiet ${beforetag-t.before} -- ':.' ':!debian/patches'
24
25         local etypes bwtip
26
27         LC_MESSAGES=C t-git-debrebase status >../status.check
28         case $state in
29         laundered)
30                 egrep '^  *branch is laundered' ../status.check
31                 ;;
32         stitched|pushed)
33                 egrep \
34  '^  *branch contains furniture|^  *branch is unlaundered|^  *branch needs laundering' ../status.check
35                 egrep '^  stitched$' ../status.check
36                 ;;
37         esac
38
39         # etypes is either a type,
40         # or   PseudoMerge-<more etypes>
41         # or   AddPatches-<more etypes>
42
43         case $state in
44         laundered)
45                         etypes=Upstream
46                         bwtip=Y:`t-git-debrebase breakwater`
47                 ;;
48         stitched)       etypes=Pseudomerge-Upstream ;;
49         pushed)         etypes=AddPatches-Pseudomerge-Upstream ;;
50         pushed-interop) etypes=Pseudomerge-AddPatchesInterop-Upstream ;;
51         esac
52
53         t-git-debrebase analyse >../anal.check
54         expect=`git rev-parse HEAD`
55         exec <../anal.check
56         local cid ctype info nparents
57         while read cid ctype info; do
58                 : ===== $cid $ctype $info =====
59                 test $cid = $expect
60                 local cetype=${etypes%%-*}
61                 if [ "x$ctype" = "x$cetype" ]; then cetype=SAME; fi
62                 local parents="`git log -n1 --pretty=format:%P $cid`"
63                 expect="$parents"
64                 enparents=1
65                 : "$ctype/$cetype" "$parents"
66
67                 case "$ctype/$cetype" in
68                 Pseudomerge/SAME)                       ;;
69                 Packaging/SAME)                         ;;
70                 Packaging/Upstream)                     ;;
71                 AddPatches/SAME)                        ;;
72                 AddPatches/AddPatchesInterop)           ;;
73                 Changelog/Packaging)                    ;;
74                 Changelog/Upstream)                     ;;
75                 Upstream/SAME)                          ;;
76                 Anchor/Upstream)                        ;;
77                 Anchor/Packaging)                       ;;
78                 *)
79                         fail "etypes=$etypes ctype=$ctype cetype=$cetype $cid"
80                         ;;
81                 esac
82
83                 case "$ctype/$etypes" in
84                 Packaging/Upstream|\
85                 Changelog/Upstream)
86                         if [ "x$bwtip" != x ]; then
87                                 test "$bwtip" = "Y:$cid"
88                                 bwtip=''
89                         fi
90                 esac
91
92                 case "$cetype" in
93                 AddPatchesInterop)
94                         git log -n1 --pretty=format:%B \
95                         | grep '^\[git-debrebase[ :]'
96                         ;;
97                 esac
98
99                 case "$ctype" in
100                 Pseudomerge)
101                         expect=${info#Contributor=}
102                         expect=${expect%% *}
103                         enparents=2
104                         git diff --quiet $expect..$cid
105                         etypes=${etypes#*-}
106
107                         : 'reject pointless pseudomerges'
108                         local overwritten=${parents/$expect/}
109                         overwritten=${overwritten// /}
110                         t-git-debrebase analyse $overwritten >../anal.overwr
111                         local ocid otype oinfo
112                         read <../anal.overwr ocid otype oinfo
113                         case "$otype" in
114                         Pseudomerge) test "x$info" != "x$oinfo" ;;
115                         esac
116                         ;;
117                 Packaging)
118                         git diff --quiet $expect..$cid -- ':.' ':!debian' 
119                         git diff --quiet $expect..$cid -- ':debian/patches'
120                         etypes=Packaging
121                         ;;
122                 AddPatches)
123                         git diff --quiet $expect..$cid -- \
124                                 ':.' ':!debian/patches'
125                         etypes=${etypes#*-}
126                         ;;
127                 Changelog)
128                         git diff --quiet $expect..$cid -- \
129                                 ':.' ':!debian/changelog'
130                         etypes=Packaging
131                         ;;
132                 Upstream/SAME)
133                         git diff --quiet $expect..$cid -- ':debian'
134                         ;;
135                 Anchor)
136                         break
137                         ;;
138                 esac
139
140                 local cnparents=`printf "%s" "$parents" | wc -w`
141                 test $cnparents = $enparents
142
143                 local cndparents=`
144         for f in $parents; do echo $f; done | t-sort -u | wc -w
145                                 `
146                 test $cndparents = $cnparents
147
148                 case "$parents" in
149                 *"$expect"*)    ;;
150                 *)              fail 'unexpected parent' ;;
151                 esac
152
153         done
154 }
155
156 t-some-changes () {
157         local token=$1
158         local which=${2-dum}
159
160         t-git-next-date
161
162         case "$which" in
163         *d*)
164                 echo >>debian/zorkmid "// debian $token"
165                 git add debian/zorkmid
166                 git commit -m "DEBIAN add zorkmid ($token)"
167                 ;;
168         esac
169
170         case "$which" in
171         *u*)
172                 echo >>src.c "// upstream $token"
173                 git commit -a -m "UPSTREAM edit src.c ($token)"
174                 ;;
175         esac
176
177         case "$which" in
178         *m*)
179                 for f in debian/zorkmid src.c; do
180                         echo "// both! $token" >>$f
181                         git add $f
182                 done
183                 git commit -m "MIXED add both ($token)"
184                 ;;
185         esac
186
187         t-git-next-date
188 }
189
190 t-make-new-upstream-tarball () {
191         local uv=$1
192         git checkout make-upstream
193         # leaves ust set to filename of orig tarball
194         echo "upstream $uv" >>docs/README
195         git commit -a -m "upstream $uv tarball"
196         ust=example_$uv.orig.tar.gz
197         git archive -o ../$ust --prefix=example-2.0/ make-upstream
198 }
199
200 t-nmu-upload-1 () {
201         # usage:
202         #  v=<full version>
203         #  nmu-upload-1 <nmubranch>
204         #  gbp pq import or perhaps other similar things
205         #  nmu-upload-2
206         #  maybe make some dgit-covertible commits
207         #  nmu-upload-3
208
209         t-git-next-date
210         nmubranch=$1
211         git checkout -f -b $nmubranch
212         t-git-debrebase
213         t-git-debrebase convert-to-gbp
214         t-git-next-date
215         # now we are on a gbp patched-unapplied branch
216 }
217
218
219 t-nmu-upload-2 () {
220         t-git-next-date
221         t-dch-commit -v $v -m "nmu $nmubranch $v"
222 }
223
224 t-nmu-upload-3 () {
225         t-dch-commit-r
226
227         t-dgit -wgf build-source
228
229         cd ..
230         c=${p}_${v}_source.changes
231         debsign -kBCD22CD83243B79D3DFAC33EA3DBCBC039B13D8A $c
232         dput -c $tmp/dput.cf test-dummy $c
233
234         t-archive-process-incoming sid
235         t-git-next-date
236         cd $p
237         git checkout master
238 }
239
240 t-nmu-commit-an-upstream-change () {
241         echo >>newsrc.c "// more upstream"
242         git add newsrc.c
243         git commit -m 'UPSTREAM NMU'
244 }
245
246 t-maintainer-commit-some-changes () {
247         t-dch-commit -v$v -m "start $v"
248
249         t-some-changes "maintainer $v"
250         t-git-debrebase
251         t-git-debrebase stitch
252
253         git branch did.maintainer
254
255         t-git-next-date
256 }
257
258 t-nmu-causes-ff-fail () {
259         t-dgit fetch
260
261         t-expect-fail E:'Not.*fast-forward' \
262         git merge --ff-only dgit/dgit/sid
263
264         t-expect-fail E:'-fdiverged.*refs/remotes/dgit/dgit/sid' \
265         t-git-debrebase
266 }
267
268 t-nmu-reconciled-good () {
269         local nmutree=$1
270
271         : 'check that what we have is what is expected'
272
273         git checkout -b compare.nmu origin/master~0
274         git checkout $nmutree .
275         git rm -rf debian/patches
276         git commit -m 'rm patches nmu'
277
278         git checkout -b compare.maintainer origin/master~0
279         git checkout did.maintainer .
280         git rm -rf --ignore-unmatch debian/patches
281         git commit --allow-empty -m 'rm patches maintainer'
282
283         git merge compare.nmu
284         git diff --quiet master
285
286         : 'check that dgit still likes it'
287
288         git checkout master
289         t-dgit -wgf quilt-fixup
290 }