Merge lp:~al-maisan/bzr-builddeb/missing-tests into lp:~bzr-builddeb-hackers/bzr-builddeb/trunk-old
- missing-tests
- Merge into trunk-old
Proposed by
Muharem Hrnjadovic
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~al-maisan/bzr-builddeb/missing-tests |
Merge into: | lp:~bzr-builddeb-hackers/bzr-builddeb/trunk-old |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~al-maisan/bzr-builddeb/missing-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email: mp+10855@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote : | # |
Revision history for this message
James Westby (james-w) wrote : | # |
Looks good.
Thanks,
James
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'import_dsc.py' |
2 | --- import_dsc.py 2009-08-28 14:12:03 +0000 |
3 | +++ import_dsc.py 2009-08-28 16:49:59 +0000 |
4 | @@ -1079,7 +1079,7 @@ |
5 | return real_parents |
6 | |
7 | def _fetch_upstream_to_branch(self, revid): |
8 | - """Fetch the revision from the upstream branch in to the pacakging one. |
9 | + """Fetch the revision from the upstream branch in to the packaging one. |
10 | """ |
11 | # Make sure we see any revisions added by the upstream branch |
12 | # since self.tree was locked. |
13 | |
14 | === modified file 'tests/blackbox/__init__.py' |
15 | --- tests/blackbox/__init__.py 2008-08-27 11:57:30 +0000 |
16 | +++ tests/blackbox/__init__.py 2009-08-28 16:39:39 +0000 |
17 | @@ -27,6 +27,7 @@ |
18 | 'test_do', |
19 | 'test_import_dsc', |
20 | 'test_mark_uploaded', |
21 | + 'test_merge_package', |
22 | 'test_merge_upstream', |
23 | ] |
24 | loader = TestUtil.TestLoader() |
25 | |
26 | === added file 'tests/blackbox/test_merge_package.py' |
27 | --- tests/blackbox/test_merge_package.py 1970-01-01 00:00:00 +0000 |
28 | +++ tests/blackbox/test_merge_package.py 2009-08-28 16:48:42 +0000 |
29 | @@ -0,0 +1,207 @@ |
30 | +# test_builddeb.py -- Blackbox tests for builddeb. |
31 | +# Copyright (C) 2009 Canonical Ltd. |
32 | +# |
33 | +# This file is part of bzr-builddeb. |
34 | +# |
35 | +# bzr-builddeb is free software; you can redistribute it and/or modify |
36 | +# it under the terms of the GNU General Public License as published by |
37 | +# the Free Software Foundation; either version 2 of the License, or |
38 | +# (at your option) any later version. |
39 | +# |
40 | +# bzr-builddeb is distributed in the hope that it will be useful, |
41 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
42 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
43 | +# GNU General Public License for more details. |
44 | +# |
45 | +# You should have received a copy of the GNU General Public License |
46 | +# along with bzr-builddeb; if not, write to the Free Software |
47 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
48 | +# |
49 | + |
50 | +import os |
51 | +import string |
52 | + |
53 | +from bzrlib.plugins.builddeb.tests import BuilddebTestCase |
54 | + |
55 | + |
56 | +_Debian_changelog = '''\ |
57 | +ipsec-tools (%s) unstable; urgency=high |
58 | + |
59 | + * debian packaging -- %s |
60 | + |
61 | + -- Nico Golde <nion@debian.org> Tue, %02d May 2009 13:26:14 +0200 |
62 | + |
63 | +''' |
64 | + |
65 | +_Ubuntu_changelog = '''\ |
66 | +ipsec-tools (%s) karmic; urgency=low |
67 | + |
68 | + * ubuntu packaging -- %s |
69 | + |
70 | + -- Jamie Strandboge <jamie@ubuntu.com> Fri, %02d Jul 2009 13:24:17 -0500 |
71 | + |
72 | +''' |
73 | + |
74 | + |
75 | +def _prepend_log(text, path): |
76 | + content = open(path).read() |
77 | + fh = open(path, 'wb') |
78 | + try: |
79 | + fh.write(text+content) |
80 | + finally: |
81 | + fh.close() |
82 | + |
83 | + |
84 | +class TestMergePackageBB(BuilddebTestCase): |
85 | + |
86 | + def test_merge_package_shared_rev_conflict(self): |
87 | + """Source upstream conflicts with target packaging -> Error. |
88 | + |
89 | + The debian upstream and the ubuntu packaging branches will differ |
90 | + with respect to the content of the file 'c'. |
91 | + |
92 | + The conflict cannot be resolved by fix_ancestry_as_needed(). |
93 | + The `SharedUpstreamConflictsWithTargetPackaging` exception is |
94 | + thrown instead. |
95 | + """ |
96 | + target, _source = self.make_conflicting_branches_setup() |
97 | + os.chdir('ubup-o') |
98 | + merge_source = '../debp-n' |
99 | + self.run_bzr_error( |
100 | + ['branches for the merge source and target have diverged'], |
101 | + 'merge-package %s' % merge_source) |
102 | + |
103 | + def make_conflicting_branches_setup(self): |
104 | + """ |
105 | + Set up the following test configuration (debian upstream newer). |
106 | + |
107 | + debian-upstream ,------------------H |
108 | + A-----------B \ |
109 | + ubuntu-upstream \ \`-------G \ |
110 | + \ \ \ \ |
111 | + debian-packaging \ ,---------D--------\-----------J |
112 | + C \ |
113 | + ubuntu-packaging `----E---------------I |
114 | + |
115 | + where: |
116 | + - A = 1.0 |
117 | + - B = 1.1 |
118 | + - H = 2.0 |
119 | + |
120 | + - G = 1.1.2 |
121 | + |
122 | + - C = 1.0-1 |
123 | + - D = 1.1-1 |
124 | + - J = 2.0-1 |
125 | + |
126 | + - E = 1.0-1ubuntu1 |
127 | + - I = 1.1.2-0ubuntu1 |
128 | + |
129 | + Please note that the debian upstream and the ubuntu packaging |
130 | + branches will have a conflict with respect to the file 'c'. |
131 | + """ |
132 | + # Set up the debian upstream branch. |
133 | + name = 'debu-n' |
134 | + vdata = [ |
135 | + ('upstream-1.0', ('a',), None, None), |
136 | + ('upstream-1.1', ('b',), None, None), |
137 | + ('upstream-2.0', ('c',), None, None)] |
138 | + debu_n = self._setup_branch(name, vdata) |
139 | + |
140 | + # Set up the debian packaging branch. |
141 | + name = 'debp-n' |
142 | + debp_n = self.make_branch_and_tree(name) |
143 | + debp_n.pull(debu_n.branch, stop_revision=self.revid_debu_n_A) |
144 | + |
145 | + vdata = [ |
146 | + ('1.0-1', ('debian/', 'debian/changelog'), None, None), |
147 | + ('1.1-1', ('o',), debu_n, self.revid_debu_n_B), |
148 | + ('2.0-1', ('p',), debu_n, self.revid_debu_n_C)] |
149 | + self._setup_branch(name, vdata, debp_n, 'd') |
150 | + |
151 | + # Set up the ubuntu upstream branch. |
152 | + name = 'ubuu-o' |
153 | + ubuu_o = debu_n.bzrdir.sprout( |
154 | + name, revision_id=self.revid_debu_n_B).open_workingtree() |
155 | + |
156 | + vdata = [('upstream-1.1.2', (), None, None)] |
157 | + self._setup_branch(name, vdata, ubuu_o) |
158 | + |
159 | + # Set up the ubuntu packaging branch. |
160 | + name = 'ubup-o' |
161 | + ubup_o = debu_n.bzrdir.sprout( |
162 | + name, revision_id=self.revid_debu_n_A).open_workingtree() |
163 | + |
164 | + vdata = [ |
165 | + ('1.0-1ubuntu1', (), debp_n, self.revid_debp_n_A), |
166 | + ('1.1.2-0ubuntu1', ('c',), ubuu_o, self.revid_ubuu_o_A)] |
167 | + self._setup_branch(name, vdata, ubup_o, 'u') |
168 | + |
169 | + # Return the ubuntu and the debian packaging branches. |
170 | + return (ubup_o, debp_n) |
171 | + |
172 | + def _setup_branch(self, name, vdata, tree=None, log_format=None): |
173 | + vids = list(string.ascii_uppercase) |
174 | + days = range(len(string.ascii_uppercase)) |
175 | + |
176 | + if tree is None: |
177 | + tree = self.make_branch_and_tree(name) |
178 | + |
179 | + def revid_name(vid): |
180 | + return 'revid_%s_%s' % (name.replace('-', '_'), vid) |
181 | + |
182 | + def add_paths(paths): |
183 | + qpaths = ['%s/%s' % (name, path) for path in paths] |
184 | + self.build_tree(qpaths) |
185 | + tree.add(paths) |
186 | + |
187 | + def changelog(vdata, vid): |
188 | + result = '' |
189 | + day = days.pop(0) |
190 | + if isinstance(vdata, tuple): |
191 | + uver, dver = vdata[:2] |
192 | + ucle = _Ubuntu_changelog % (uver, vid, day) |
193 | + dcle = _Debian_changelog % (dver, vid, day) |
194 | + result = ucle + dcle |
195 | + else: |
196 | + if log_format == 'u': |
197 | + result = _Ubuntu_changelog % (vdata, vid, day) |
198 | + elif log_format == 'd': |
199 | + result = _Debian_changelog % (vdata, vid, day) |
200 | + |
201 | + return result |
202 | + |
203 | + def commit(msg, version): |
204 | + vid = vids.pop(0) |
205 | + if log_format is not None: |
206 | + cle = changelog(version, vid) |
207 | + p = '%s/work/%s/debian/changelog' % (self.test_base_dir, name) |
208 | + _prepend_log(cle, p) |
209 | + revid = tree.commit('%s: %s' % (vid, msg)) |
210 | + setattr(self, revid_name(vid), revid) |
211 | + tree.branch.tags.set_tag(version, revid) |
212 | + |
213 | + def tree_nick(tree): |
214 | + return str(tree)[1:-1].split('/')[-1] |
215 | + |
216 | + tree.lock_write() |
217 | + |
218 | + try: |
219 | + for version, paths, utree, urevid in vdata: |
220 | + msg = '' |
221 | + if utree is not None: |
222 | + tree.merge_from_branch(utree.branch, to_revision=urevid) |
223 | + utree.branch.tags.merge_to(tree.branch.tags) |
224 | + if urevid is not None: |
225 | + msg += 'Merged tree %s|%s. ' % (tree_nick(utree), urevid) |
226 | + else: |
227 | + msg += 'Merged tree %s. ' % utree |
228 | + if paths is not None: |
229 | + add_paths(paths) |
230 | + msg += 'Added paths: %s. ' % str(paths) |
231 | + |
232 | + commit(msg, version) |
233 | + finally: |
234 | + tree.unlock() |
235 | + |
236 | + return tree |
237 | |
238 | === modified file 'tests/test_merge_package.py' |
239 | --- tests/test_merge_package.py 2009-08-24 10:47:13 +0000 |
240 | +++ tests/test_merge_package.py 2009-08-28 16:39:39 +0000 |
241 | @@ -1,7 +1,7 @@ |
242 | #!/usr/bin/env python |
243 | # -*- coding: iso-8859-15 -*- |
244 | # test_merge_package.py -- Merge packaging branches, fix ancestry as needed. |
245 | -# Copyright (C) 2008 Canonical Ltd. |
246 | +# Copyright (C) 2009 Canonical Ltd. |
247 | # |
248 | # This file is part of bzr-builddeb. |
249 | # |
250 | @@ -28,6 +28,8 @@ |
251 | from bzrlib.tests import TestCaseWithTransport |
252 | |
253 | from bzrlib.plugins.builddeb import merge_package as MP |
254 | +from bzrlib.plugins.builddeb.errors import ( |
255 | + SharedUpstreamConflictsWithTargetPackaging) |
256 | from bzrlib.plugins.builddeb.import_dsc import DistributionBranch |
257 | |
258 | _Debian_changelog = '''\ |
259 | @@ -161,6 +163,25 @@ |
260 | conflict_paths = sorted([c.path for c in ubup.conflicts()]) |
261 | self.assertEquals(conflict_paths, [u'debian/changelog']) |
262 | |
263 | + def test_deb_upstream_coflicts_with_ubu_packaging(self): |
264 | + """Source upstream conflicts with target packaging -> exception. |
265 | + |
266 | + The debian upstream and the ubuntu packaging branches will differ |
267 | + with respect to the content of the file 'c'. |
268 | + |
269 | + The conflict cannot be resolved by fix_ancestry_as_needed(). |
270 | + The `SharedUpstreamConflictsWithTargetPackaging` exception is |
271 | + thrown instead. |
272 | + """ |
273 | + ubup, debp, ubuu, debu = self._setup_debian_upstream_conflicts() |
274 | + |
275 | + e = self.assertRaises( |
276 | + SharedUpstreamConflictsWithTargetPackaging, |
277 | + MP.fix_ancestry_as_needed, ubup, debp.branch) |
278 | + |
279 | + conflict_paths = sorted([c.path for c in ubup.conflicts()]) |
280 | + self.assertEquals(conflict_paths, [u'c.moved']) |
281 | + |
282 | def test_debian_upstream_older(self): |
283 | """Diverging upstreams (debian older) don't cause merge conflicts. |
284 | |
285 | @@ -274,8 +295,8 @@ |
286 | - E = 1.0-1ubuntu1 |
287 | - I = 1.1.2-0ubuntu1 |
288 | |
289 | - Please note that the debian and ubuntu branches will have a conflict |
290 | - with respect to the file 'c'. |
291 | + Please note that the debian and ubuntu *upstream* branches will |
292 | + have a conflict with respect to the file 'c'. |
293 | """ |
294 | # Set up the debian upstream branch. |
295 | name = 'debu-n' |
296 | @@ -322,6 +343,80 @@ |
297 | # Return the ubuntu and the debian packaging branches. |
298 | return (ubup_o, debp_n, ubuu_o, debu_n) |
299 | |
300 | + def _setup_debian_upstream_conflicts(self): |
301 | + """ |
302 | + Set up the following test configuration (debian upstream newer). |
303 | + |
304 | + debian-upstream ,------------------H |
305 | + A-----------B \ |
306 | + ubuntu-upstream \ \`-------G \ |
307 | + \ \ \ \ |
308 | + debian-packaging \ ,---------D--------\-----------J |
309 | + C \ |
310 | + ubuntu-packaging `----E---------------I |
311 | + |
312 | + where: |
313 | + - A = 1.0 |
314 | + - B = 1.1 |
315 | + - H = 2.0 |
316 | + |
317 | + - G = 1.1.2 |
318 | + |
319 | + - C = 1.0-1 |
320 | + - D = 1.1-1 |
321 | + - J = 2.0-1 |
322 | + |
323 | + - E = 1.0-1ubuntu1 |
324 | + - I = 1.1.2-0ubuntu1 |
325 | + |
326 | + Please note that the debian upstream and the ubuntu packaging |
327 | + branches will have a conflict with respect to the file 'c'. |
328 | + """ |
329 | + # Set up the debian upstream branch. |
330 | + name = 'debu-n' |
331 | + vdata = [ |
332 | + ('upstream-1.0', ('a',), None, None), |
333 | + ('upstream-1.1', ('b',), None, None), |
334 | + ('upstream-2.0', ('c',), None, None), |
335 | + ] |
336 | + debu_n = self._setup_branch(name, vdata) |
337 | + |
338 | + # Set up the debian packaging branch. |
339 | + name = 'debp-n' |
340 | + debp_n = self.make_branch_and_tree(name) |
341 | + debp_n.pull(debu_n.branch, stop_revision=self.revid_debu_n_A) |
342 | + |
343 | + vdata = [ |
344 | + ('1.0-1', ('debian/', 'debian/changelog'), None, None), |
345 | + ('1.1-1', ('o',), debu_n, self.revid_debu_n_B), |
346 | + ('2.0-1', ('p',), debu_n, self.revid_debu_n_C), |
347 | + ] |
348 | + self._setup_branch(name, vdata, debp_n, 'd') |
349 | + |
350 | + # Set up the ubuntu upstream branch. |
351 | + name = 'ubuu-o' |
352 | + ubuu_o = debu_n.bzrdir.sprout( |
353 | + name, revision_id=self.revid_debu_n_B).open_workingtree() |
354 | + |
355 | + vdata = [ |
356 | + ('upstream-1.1.2', (), None, None), |
357 | + ] |
358 | + self._setup_branch(name, vdata, ubuu_o) |
359 | + |
360 | + # Set up the ubuntu packaging branch. |
361 | + name = 'ubup-o' |
362 | + ubup_o = debu_n.bzrdir.sprout( |
363 | + name, revision_id=self.revid_debu_n_A).open_workingtree() |
364 | + |
365 | + vdata = [ |
366 | + ('1.0-1ubuntu1', (), debp_n, self.revid_debp_n_A), |
367 | + ('1.1.2-0ubuntu1', ('c',), ubuu_o, self.revid_ubuu_o_A), |
368 | + ] |
369 | + self._setup_branch(name, vdata, ubup_o, 'u') |
370 | + |
371 | + # Return the ubuntu and the debian packaging branches. |
372 | + return (ubup_o, debp_n, ubuu_o, debu_n) |
373 | + |
374 | def _setup_debian_upstream_older(self): |
375 | """ |
376 | Set up the following test configuration (debian upstream older). |
Hello,
this branch adds a unit and a black-box test for the case where a source upstream branch conflicts with a target packaging branch.
Please take a look.