OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for checkout.py.""" | 6 """Unit tests for checkout.py.""" |
7 | 7 |
8 from __future__ import with_statement | 8 from __future__ import with_statement |
9 import logging | 9 import logging |
10 import os | 10 import os |
11 import shutil | 11 import shutil |
12 import sys | 12 import sys |
13 import unittest | 13 import unittest |
14 from xml.etree import ElementTree | 14 from xml.etree import ElementTree |
15 | 15 |
16 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | 16 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
17 BASE_DIR = os.path.join(ROOT_DIR, '..') | 17 BASE_DIR = os.path.join(ROOT_DIR, '..') |
18 sys.path.insert(0, BASE_DIR) | 18 sys.path.insert(0, BASE_DIR) |
19 | 19 |
20 import checkout | 20 import checkout |
21 import patch | 21 import patch |
22 import subprocess2 | 22 import subprocess2 |
23 from tests import fake_repos | 23 from tests import fake_repos |
| 24 from tests.patches_data import GIT, RAW |
24 | 25 |
25 | 26 |
26 # pass -v to enable it. | 27 # pass -v to enable it. |
27 DEBUGGING = False | 28 DEBUGGING = False |
28 | 29 |
29 # A naked patch. | |
30 NAKED_PATCH = ("""\ | |
31 --- svn_utils_test.txt | |
32 +++ svn_utils_test.txt | |
33 @@ -3,6 +3,7 @@ bb | |
34 ccc | |
35 dd | |
36 e | |
37 +FOO! | |
38 ff | |
39 ggg | |
40 hh | |
41 """) | |
42 | |
43 # A patch generated from git. | |
44 GIT_PATCH = ("""\ | |
45 diff --git a/svn_utils_test.txt b/svn_utils_test.txt | |
46 index 0e4de76..8320059 100644 | |
47 --- a/svn_utils_test.txt | |
48 +++ b/svn_utils_test.txt | |
49 @@ -3,6 +3,7 @@ bb | |
50 ccc | |
51 dd | |
52 e | |
53 +FOO! | |
54 ff | |
55 ggg | |
56 hh | |
57 """) | |
58 | |
59 # A patch that will fail to apply. | 30 # A patch that will fail to apply. |
60 BAD_PATCH = ("""\ | 31 BAD_PATCH = ''.join( |
61 diff --git a/svn_utils_test.txt b/svn_utils_test.txt | 32 [l for l in GIT.PATCH.splitlines(True) if l.strip() != 'e']) |
62 index 0e4de76..8320059 100644 | |
63 --- a/svn_utils_test.txt | |
64 +++ b/svn_utils_test.txt | |
65 @@ -3,7 +3,8 @@ bb | |
66 ccc | |
67 dd | |
68 +FOO! | |
69 ff | |
70 ggg | |
71 hh | |
72 """) | |
73 | |
74 PATCH_ADD = ("""\ | |
75 diff --git a/new_dir/subdir/new_file b/new_dir/subdir/new_file | |
76 new file mode 100644 | |
77 --- /dev/null | |
78 +++ b/new_dir/subdir/new_file | |
79 @@ -0,0 +1,2 @@ | |
80 +A new file | |
81 +should exist. | |
82 """) | |
83 | 33 |
84 | 34 |
85 class FakeRepos(fake_repos.FakeReposBase): | 35 class FakeRepos(fake_repos.FakeReposBase): |
86 def populateSvn(self): | 36 def populateSvn(self): |
87 """Creates a few revisions of changes files.""" | 37 """Creates a few revisions of changes files.""" |
88 subprocess2.check_call( | 38 subprocess2.check_call( |
89 ['svn', 'checkout', self.svn_base, self.svn_checkout, '-q', | 39 ['svn', 'checkout', self.svn_base, self.svn_checkout, '-q', |
90 '--non-interactive', '--no-auth-cache', | 40 '--non-interactive', '--no-auth-cache', |
91 '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) | 41 '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) |
92 assert os.path.isdir(os.path.join(self.svn_checkout, '.svn')) | 42 assert os.path.isdir(os.path.join(self.svn_checkout, '.svn')) |
93 fs = {} | 43 fs = {} |
94 fs['trunk/origin'] = 'svn@1' | 44 fs['trunk/origin'] = 'svn@1' |
95 fs['trunk/codereview.settings'] = ( | 45 fs['trunk/codereview.settings'] = ( |
96 '# Test data\n' | 46 '# Test data\n' |
97 'bar: pouet\n') | 47 'bar: pouet\n') |
98 fs['trunk/svn_utils_test.txt'] = ( | 48 fs['trunk/chrome/file.cc'] = ( |
99 'a\n' | 49 'a\n' |
100 'bb\n' | 50 'bb\n' |
101 'ccc\n' | 51 'ccc\n' |
102 'dd\n' | 52 'dd\n' |
103 'e\n' | 53 'e\n' |
104 'ff\n' | 54 'ff\n' |
105 'ggg\n' | 55 'ggg\n' |
106 'hh\n' | 56 'hh\n' |
107 'i\n' | 57 'i\n' |
108 'jj\n' | 58 'jj\n' |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 subprocess2.call = redirect_call | 92 subprocess2.call = redirect_call |
143 self.usr, self.pwd = self.FAKE_REPOS.USERS[0] | 93 self.usr, self.pwd = self.FAKE_REPOS.USERS[0] |
144 self.previous_log = None | 94 self.previous_log = None |
145 | 95 |
146 def tearDown(self): | 96 def tearDown(self): |
147 subprocess2.call = self._old_call | 97 subprocess2.call = self._old_call |
148 super(BaseTest, self).tearDown() | 98 super(BaseTest, self).tearDown() |
149 | 99 |
150 def get_patches(self): | 100 def get_patches(self): |
151 return patch.PatchSet([ | 101 return patch.PatchSet([ |
152 patch.FilePatchDiff( | |
153 'svn_utils_test.txt', GIT_PATCH, []), | |
154 # TODO(maruel): Test with is_new == False. | 102 # TODO(maruel): Test with is_new == False. |
155 patch.FilePatchBinary('bin_file', '\x00', [], is_new=True), | 103 patch.FilePatchBinary('bin_file', '\x00', [], is_new=True), |
| 104 patch.FilePatchDiff( |
| 105 'chrome/file.cc', GIT.PATCH, []), |
| 106 patch.FilePatchDiff('new_dir/subdir/new_file', GIT.NEW_SUBDIR, []), |
156 patch.FilePatchDelete('extra', False), | 107 patch.FilePatchDelete('extra', False), |
157 patch.FilePatchDiff('new_dir/subdir/new_file', PATCH_ADD, []), | |
158 ]) | 108 ]) |
159 | 109 |
160 def get_trunk(self, modified): | 110 def get_trunk(self, modified): |
161 tree = {} | 111 tree = {} |
162 subroot = 'trunk/' | 112 subroot = 'trunk/' |
163 for k, v in self.FAKE_REPOS.svn_revs[-1].iteritems(): | 113 for k, v in self.FAKE_REPOS.svn_revs[-1].iteritems(): |
164 if k.startswith(subroot): | 114 if k.startswith(subroot): |
165 f = k[len(subroot):] | 115 f = k[len(subroot):] |
166 assert f not in tree | 116 assert f not in tree |
167 tree[f] = v | 117 tree[f] = v |
168 | 118 |
169 if modified: | 119 if modified: |
170 content_lines = tree['svn_utils_test.txt'].splitlines(True) | 120 content_lines = tree['chrome/file.cc'].splitlines(True) |
171 tree['svn_utils_test.txt'] = ''.join( | 121 tree['chrome/file.cc'] = ''.join( |
172 content_lines[0:5] + ['FOO!\n'] + content_lines[5:]) | 122 content_lines[0:5] + ['FOO!\n'] + content_lines[5:]) |
173 del tree['extra'] | 123 del tree['extra'] |
174 tree['new_dir/subdir/new_file'] = 'A new file\nshould exist.\n' | 124 tree['new_dir/subdir/new_file'] = 'A new file\nshould exist.\n' |
175 return tree | 125 return tree |
176 | 126 |
177 def _check_base(self, co, root, git, expected): | 127 def _check_base(self, co, root, git, expected): |
178 read_only = isinstance(co, checkout.ReadOnlyCheckout) | 128 read_only = isinstance(co, checkout.ReadOnlyCheckout) |
179 assert not read_only == bool(expected) | 129 assert not read_only == bool(expected) |
180 if not read_only: | 130 if not read_only: |
181 self.FAKE_REPOS.svn_dirty = True | 131 self.FAKE_REPOS.svn_dirty = True |
182 | 132 |
183 self.assertEquals(root, co.project_path) | 133 self.assertEquals(root, co.project_path) |
184 self.assertEquals(self.previous_log['revision'], co.prepare(None)) | 134 self.assertEquals(self.previous_log['revision'], co.prepare(None)) |
185 self.assertEquals('pouet', co.get_settings('bar')) | 135 self.assertEquals('pouet', co.get_settings('bar')) |
186 self.assertTree(self.get_trunk(False), root) | 136 self.assertTree(self.get_trunk(False), root) |
187 patches = self.get_patches() | 137 patches = self.get_patches() |
188 co.apply_patch(patches) | 138 co.apply_patch(patches) |
189 self.assertEquals( | 139 self.assertEquals( |
190 ['bin_file', 'extra', 'new_dir/subdir/new_file', 'svn_utils_test.txt'], | 140 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], |
191 sorted(patches.filenames)) | 141 patches.filenames) |
192 | 142 |
193 if git: | 143 if git: |
194 # Hackish to verify _branches() internal function. | 144 # Hackish to verify _branches() internal function. |
195 # pylint: disable=W0212 | 145 # pylint: disable=W0212 |
196 self.assertEquals( | 146 self.assertEquals( |
197 (['master', 'working_branch'], 'working_branch'), | 147 (['master', 'working_branch'], 'working_branch'), |
198 co.checkout._branches()) | 148 co.checkout._branches()) |
199 | 149 |
200 # Verify that the patch is applied even for read only checkout. | 150 # Verify that the patch is applied even for read only checkout. |
201 self.assertTree(self.get_trunk(True), root) | 151 self.assertTree(self.get_trunk(True), root) |
(...skipping 16 matching lines...) Expand all Loading... |
218 expected['msg'] = 'msg' | 168 expected['msg'] = 'msg' |
219 expected['revision'] = self.previous_log['revision'] + 1 | 169 expected['revision'] = self.previous_log['revision'] + 1 |
220 expected.setdefault('author', fake_author) | 170 expected.setdefault('author', fake_author) |
221 | 171 |
222 actual = self._log() | 172 actual = self._log() |
223 self.assertEquals(expected, actual) | 173 self.assertEquals(expected, actual) |
224 | 174 |
225 def _check_exception(self, co, err_msg): | 175 def _check_exception(self, co, err_msg): |
226 co.prepare(None) | 176 co.prepare(None) |
227 try: | 177 try: |
228 co.apply_patch([patch.FilePatchDiff('svn_utils_test.txt', BAD_PATCH, [])]) | 178 co.apply_patch([patch.FilePatchDiff('chrome/file.cc', BAD_PATCH, [])]) |
229 self.fail() | 179 self.fail() |
230 except checkout.PatchApplicationFailed, e: | 180 except checkout.PatchApplicationFailed, e: |
231 self.assertEquals(e.filename, 'svn_utils_test.txt') | 181 self.assertEquals(e.filename, 'chrome/file.cc') |
232 self.assertEquals(e.status, err_msg) | 182 self.assertEquals(e.status, err_msg) |
233 | 183 |
234 def _log(self): | 184 def _log(self): |
235 raise NotImplementedError() | 185 raise NotImplementedError() |
236 | 186 |
237 def _test_process(self, co_lambda): | 187 def _test_process(self, co_lambda): |
238 """Makes sure the process lambda is called correctly.""" | 188 """Makes sure the process lambda is called correctly.""" |
239 post_processors = [lambda *args: results.append(args)] | 189 post_processors = [lambda *args: results.append(args)] |
240 co = co_lambda(post_processors) | 190 co = co_lambda(post_processors) |
241 self.assertEquals(post_processors, co.post_processors) | 191 self.assertEquals(post_processors, co.post_processors) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 258 } |
309 self._check(False, expected) | 259 self._check(False, expected) |
310 | 260 |
311 def testAllRO(self): | 261 def testAllRO(self): |
312 self._check(True, None) | 262 self._check(True, None) |
313 | 263 |
314 def testException(self): | 264 def testException(self): |
315 self._check_exception( | 265 self._check_exception( |
316 self._get_co(True), | 266 self._get_co(True), |
317 'While running patch -p1 --forward --force;\n' | 267 'While running patch -p1 --forward --force;\n' |
318 'patching file svn_utils_test.txt\n' | 268 'patching file chrome/file.cc\n' |
319 'Hunk #1 FAILED at 3.\n' | 269 'Hunk #1 FAILED at 3.\n' |
320 '1 out of 1 hunk FAILED -- saving rejects to file ' | 270 '1 out of 1 hunk FAILED -- saving rejects to file ' |
321 'svn_utils_test.txt.rej\n') | 271 'chrome/file.cc.rej\n') |
322 | 272 |
323 def testSvnProps(self): | 273 def testSvnProps(self): |
324 co = self._get_co(False) | 274 co = self._get_co(False) |
325 co.prepare(None) | 275 co.prepare(None) |
326 try: | 276 try: |
327 # svn:ignore can only be applied to directories. | 277 # svn:ignore can only be applied to directories. |
328 svn_props = [('svn:ignore', 'foo')] | 278 svn_props = [('svn:ignore', 'foo')] |
329 co.apply_patch( | 279 co.apply_patch( |
330 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) | 280 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) |
331 self.fail() | 281 self.fail() |
332 except checkout.PatchApplicationFailed, e: | 282 except checkout.PatchApplicationFailed, e: |
333 self.assertEquals(e.filename, 'svn_utils_test.txt') | 283 self.assertEquals(e.filename, 'chrome/file.cc') |
334 self.assertEquals( | 284 self.assertEquals( |
335 e.status, | 285 e.status, |
336 'While running svn propset svn:ignore foo svn_utils_test.txt ' | 286 'While running svn propset svn:ignore foo chrome/file.cc ' |
337 '--non-interactive;\n' | 287 '--non-interactive;\n' |
338 'patching file svn_utils_test.txt\n' | 288 'patching file chrome/file.cc\n' |
339 'svn: Cannot set \'svn:ignore\' on a file (\'svn_utils_test.txt\')\n') | 289 'svn: Cannot set \'svn:ignore\' on a file (\'chrome/file.cc\')\n') |
340 co.prepare(None) | 290 co.prepare(None) |
341 svn_props = [('svn:eol-style', 'LF'), ('foo', 'bar')] | 291 svn_props = [('svn:eol-style', 'LF'), ('foo', 'bar')] |
342 co.apply_patch( | 292 co.apply_patch( |
343 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) | 293 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) |
344 filepath = os.path.join(self.root_dir, self.name, 'svn_utils_test.txt') | 294 filepath = os.path.join(self.root_dir, self.name, 'chrome/file.cc') |
345 # Manually verify the properties. | 295 # Manually verify the properties. |
346 props = subprocess2.check_output( | 296 props = subprocess2.check_output( |
347 ['svn', 'proplist', filepath], | 297 ['svn', 'proplist', filepath], |
348 cwd=self.root_dir).splitlines()[1:] | 298 cwd=self.root_dir).splitlines()[1:] |
349 props = sorted(p.strip() for p in props) | 299 props = sorted(p.strip() for p in props) |
350 expected_props = dict(svn_props) | 300 expected_props = dict(svn_props) |
351 self.assertEquals(sorted(expected_props.iterkeys()), props) | 301 self.assertEquals(sorted(expected_props.iterkeys()), props) |
352 for k, v in expected_props.iteritems(): | 302 for k, v in expected_props.iteritems(): |
353 value = subprocess2.check_output( | 303 value = subprocess2.check_output( |
354 ['svn', 'propget', '--strict', k, filepath], | 304 ['svn', 'propget', '--strict', k, filepath], |
(...skipping 26 matching lines...) Expand all Loading... |
381 self._check_base(co, root, False, expected) | 331 self._check_base(co, root, False, expected) |
382 | 332 |
383 def testAutoProps(self): | 333 def testAutoProps(self): |
384 co = self._get_co(False) | 334 co = self._get_co(False) |
385 co.svn_config = checkout.SvnConfig( | 335 co.svn_config = checkout.SvnConfig( |
386 os.path.join(ROOT_DIR, 'subversion_config')) | 336 os.path.join(ROOT_DIR, 'subversion_config')) |
387 co.prepare(None) | 337 co.prepare(None) |
388 patches = self.get_patches() | 338 patches = self.get_patches() |
389 co.apply_patch(patches) | 339 co.apply_patch(patches) |
390 self.assertEquals( | 340 self.assertEquals( |
391 ['bin_file', 'extra', 'new_dir/subdir/new_file', 'svn_utils_test.txt'], | 341 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], |
392 sorted(patches.filenames)) | 342 patches.filenames) |
393 # *.txt = svn:eol-style=LF in subversion_config/config. | 343 # *.txt = svn:eol-style=LF in subversion_config/config. |
394 out = subprocess2.check_output( | 344 out = subprocess2.check_output( |
395 ['svn', 'pget', 'svn:eol-style', 'svn_utils_test.txt'], | 345 ['svn', 'pget', 'svn:eol-style', 'chrome/file.cc'], |
396 cwd=co.project_path) | 346 cwd=co.project_path) |
397 self.assertEquals('LF\n', out) | 347 self.assertEquals('LF\n', out) |
398 | 348 |
399 def testProcess(self): | 349 def testProcess(self): |
400 co = lambda x: checkout.SvnCheckout( | 350 co = lambda x: checkout.SvnCheckout( |
401 self.root_dir, self.name, | 351 self.root_dir, self.name, |
402 None, None, | 352 None, None, |
403 self.svn_url, | 353 self.svn_url, |
404 x) | 354 x) |
405 self._test_process(co) | 355 self._test_process(co) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 def testException(self): | 407 def testException(self): |
458 self._check_exception( | 408 self._check_exception( |
459 self._get_co(True), 'fatal: corrupt patch at line 12\n') | 409 self._get_co(True), 'fatal: corrupt patch at line 12\n') |
460 | 410 |
461 def testSvnProps(self): | 411 def testSvnProps(self): |
462 co = self._get_co(False) | 412 co = self._get_co(False) |
463 co.prepare(None) | 413 co.prepare(None) |
464 try: | 414 try: |
465 svn_props = [('foo', 'bar')] | 415 svn_props = [('foo', 'bar')] |
466 co.apply_patch( | 416 co.apply_patch( |
467 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) | 417 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) |
468 self.fail() | 418 self.fail() |
469 except patch.UnsupportedPatchFormat, e: | 419 except patch.UnsupportedPatchFormat, e: |
470 self.assertEquals(e.filename, 'svn_utils_test.txt') | 420 self.assertEquals(e.filename, 'chrome/file.cc') |
471 self.assertEquals( | 421 self.assertEquals( |
472 e.status, | 422 e.status, |
473 'Cannot apply svn property foo to file svn_utils_test.txt.') | 423 'Cannot apply svn property foo to file chrome/file.cc.') |
474 co.prepare(None) | 424 co.prepare(None) |
475 # svn:eol-style is ignored. | 425 # svn:eol-style is ignored. |
476 svn_props = [('svn:eol-style', 'LF')] | 426 svn_props = [('svn:eol-style', 'LF')] |
477 co.apply_patch( | 427 co.apply_patch( |
478 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) | 428 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) |
479 | 429 |
480 def testProcess(self): | 430 def testProcess(self): |
481 co = lambda x: checkout.SvnCheckout( | 431 co = lambda x: checkout.SvnCheckout( |
482 self.root_dir, self.name, | 432 self.root_dir, self.name, |
483 None, None, | 433 None, None, |
484 self.svn_url, x) | 434 self.svn_url, x) |
485 self._test_process(co) | 435 self._test_process(co) |
486 | 436 |
487 def testPrepare(self): | 437 def testPrepare(self): |
488 co = checkout.SvnCheckout( | 438 co = checkout.SvnCheckout( |
(...skipping 22 matching lines...) Expand all Loading... |
511 co = self._get_co(read_only) | 461 co = self._get_co(read_only) |
512 | 462 |
513 # A copy of BaseTest._check_base() | 463 # A copy of BaseTest._check_base() |
514 self.assertEquals(root, co.project_path) | 464 self.assertEquals(root, co.project_path) |
515 self.assertEquals(None, co.prepare(None)) | 465 self.assertEquals(None, co.prepare(None)) |
516 self.assertEquals('pouet', co.get_settings('bar')) | 466 self.assertEquals('pouet', co.get_settings('bar')) |
517 self.assertTree(self.get_trunk(False), root) | 467 self.assertTree(self.get_trunk(False), root) |
518 patches = self.get_patches() | 468 patches = self.get_patches() |
519 co.apply_patch(patches) | 469 co.apply_patch(patches) |
520 self.assertEquals( | 470 self.assertEquals( |
521 ['bin_file', 'extra', 'new_dir/subdir/new_file', 'svn_utils_test.txt'], | 471 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], |
522 sorted(patches.filenames)) | 472 patches.filenames) |
523 | 473 |
524 # Verify that the patch is applied even for read only checkout. | 474 # Verify that the patch is applied even for read only checkout. |
525 self.assertTree(self.get_trunk(True), root) | 475 self.assertTree(self.get_trunk(True), root) |
526 if read_only: | 476 if read_only: |
527 revision = co.commit(u'msg', self.FAKE_REPOS.USERS[1][0]) | 477 revision = co.commit(u'msg', self.FAKE_REPOS.USERS[1][0]) |
528 self.assertEquals('FAKE', revision) | 478 self.assertEquals('FAKE', revision) |
529 else: | 479 else: |
530 try: | 480 try: |
531 co.commit(u'msg', self.FAKE_REPOS.USERS[1][0]) | 481 co.commit(u'msg', self.FAKE_REPOS.USERS[1][0]) |
532 self.fail() | 482 self.fail() |
533 except NotImplementedError: | 483 except NotImplementedError: |
534 pass | 484 pass |
535 self.assertTree(self.get_trunk(True), root) | 485 self.assertTree(self.get_trunk(True), root) |
536 # Verify that prepare() is a no-op. | 486 # Verify that prepare() is a no-op. |
537 self.assertEquals(None, co.prepare(None)) | 487 self.assertEquals(None, co.prepare(None)) |
538 self.assertTree(self.get_trunk(True), root) | 488 self.assertTree(self.get_trunk(True), root) |
539 | 489 |
540 def testAllRW(self): | 490 def testAllRW(self): |
541 self._check(False) | 491 self._check(False) |
542 | 492 |
543 def testAllRO(self): | 493 def testAllRO(self): |
544 self._check(True) | 494 self._check(True) |
545 | 495 |
546 def testException(self): | 496 def testException(self): |
547 self._check_exception( | 497 self._check_exception( |
548 self._get_co(True), | 498 self._get_co(True), |
549 'patching file svn_utils_test.txt\n' | 499 'patching file chrome/file.cc\n' |
550 'Hunk #1 FAILED at 3.\n' | 500 'Hunk #1 FAILED at 3.\n' |
551 '1 out of 1 hunk FAILED -- saving rejects to file ' | 501 '1 out of 1 hunk FAILED -- saving rejects to file ' |
552 'svn_utils_test.txt.rej\n') | 502 'chrome/file.cc.rej\n') |
553 | 503 |
554 def testProcess(self): | 504 def testProcess(self): |
555 co = lambda x: checkout.SvnCheckout( | 505 co = lambda x: checkout.SvnCheckout( |
556 self.root_dir, self.name, | 506 self.root_dir, self.name, |
557 None, None, | 507 None, None, |
558 self.svn_url, x) | 508 self.svn_url, x) |
559 self._test_process(co) | 509 self._test_process(co) |
560 | 510 |
561 def testPrepare(self): | 511 def testPrepare(self): |
562 co = checkout.SvnCheckout( | 512 co = checkout.SvnCheckout( |
563 self.root_dir, self.name, | 513 self.root_dir, self.name, |
564 None, None, | 514 None, None, |
565 self.svn_url) | 515 self.svn_url) |
566 self._test_prepare(co) | 516 self._test_prepare(co) |
567 | 517 |
568 | 518 |
569 if __name__ == '__main__': | 519 if __name__ == '__main__': |
570 if '-v' in sys.argv: | 520 if '-v' in sys.argv: |
571 DEBUGGING = True | 521 DEBUGGING = True |
572 logging.basicConfig( | 522 logging.basicConfig( |
573 level=logging.DEBUG, | 523 level=logging.DEBUG, |
574 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 524 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
575 else: | 525 else: |
576 logging.basicConfig( | 526 logging.basicConfig( |
577 level=logging.ERROR, | 527 level=logging.ERROR, |
578 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 528 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
579 unittest.main() | 529 unittest.main() |
OLD | NEW |