| 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 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 'revprops': [('realauthor', self.FAKE_REPOS.USERS[1][0])] | 300 'revprops': [('realauthor', self.FAKE_REPOS.USERS[1][0])] |
| 301 } | 301 } |
| 302 self._check(False, expected) | 302 self._check(False, expected) |
| 303 | 303 |
| 304 def testAllRO(self): | 304 def testAllRO(self): |
| 305 self._check(True, None) | 305 self._check(True, None) |
| 306 | 306 |
| 307 def testException(self): | 307 def testException(self): |
| 308 self._check_exception( | 308 self._check_exception( |
| 309 self._get_co(True), | 309 self._get_co(True), |
| 310 'While running patch -p1 --forward --force;\n' |
| 310 'patching file svn_utils_test.txt\n' | 311 'patching file svn_utils_test.txt\n' |
| 311 'Hunk #1 FAILED at 3.\n' | 312 'Hunk #1 FAILED at 3.\n' |
| 312 '1 out of 1 hunk FAILED -- saving rejects to file ' | 313 '1 out of 1 hunk FAILED -- saving rejects to file ' |
| 313 'svn_utils_test.txt.rej\n') | 314 'svn_utils_test.txt.rej\n') |
| 314 | 315 |
| 315 def testSvnProps(self): | 316 def testSvnProps(self): |
| 316 co = self._get_co(False) | 317 co = self._get_co(False) |
| 317 co.prepare() | 318 co.prepare() |
| 318 try: | 319 try: |
| 319 # svn:ignore can only be applied to directories. | 320 # svn:ignore can only be applied to directories. |
| 320 svn_props = [('svn:ignore', 'foo')] | 321 svn_props = [('svn:ignore', 'foo')] |
| 321 co.apply_patch( | 322 co.apply_patch( |
| 322 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) | 323 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) |
| 323 self.fail() | 324 self.fail() |
| 324 except checkout.PatchApplicationFailed, e: | 325 except checkout.PatchApplicationFailed, e: |
| 325 self.assertEquals(e.filename, 'svn_utils_test.txt') | 326 self.assertEquals(e.filename, 'svn_utils_test.txt') |
| 326 self.assertEquals( | 327 self.assertEquals( |
| 327 e.status, | 328 e.status, |
| 328 "patching file svn_utils_test.txt\n" | 329 'While running svn propset svn:ignore foo svn_utils_test.txt ' |
| 329 "svn: Cannot set 'svn:ignore' on a file ('svn_utils_test.txt')\n") | 330 '--non-interactive;\n' |
| 331 'patching file svn_utils_test.txt\n' |
| 332 'svn: Cannot set \'svn:ignore\' on a file (\'svn_utils_test.txt\')\n') |
| 330 co.prepare() | 333 co.prepare() |
| 331 svn_props = [('svn:eol-style', 'LF'), ('foo', 'bar')] | 334 svn_props = [('svn:eol-style', 'LF'), ('foo', 'bar')] |
| 332 co.apply_patch( | 335 co.apply_patch( |
| 333 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) | 336 [patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)]) |
| 334 filepath = os.path.join(self.root_dir, self.name, 'svn_utils_test.txt') | 337 filepath = os.path.join(self.root_dir, self.name, 'svn_utils_test.txt') |
| 335 # Manually verify the properties. | 338 # Manually verify the properties. |
| 336 props = subprocess2.check_output( | 339 props = subprocess2.check_output( |
| 337 ['svn', 'proplist', filepath], | 340 ['svn', 'proplist', filepath], |
| 338 cwd=self.root_dir).splitlines()[1:] | 341 cwd=self.root_dir).splitlines()[1:] |
| 339 props = sorted(p.strip() for p in props) | 342 props = sorted(p.strip() for p in props) |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 if '-v' in sys.argv: | 540 if '-v' in sys.argv: |
| 538 DEBUGGING = True | 541 DEBUGGING = True |
| 539 logging.basicConfig( | 542 logging.basicConfig( |
| 540 level=logging.DEBUG, | 543 level=logging.DEBUG, |
| 541 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 544 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
| 542 else: | 545 else: |
| 543 logging.basicConfig( | 546 logging.basicConfig( |
| 544 level=logging.ERROR, | 547 level=logging.ERROR, |
| 545 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 548 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
| 546 unittest.main() | 549 unittest.main() |
| OLD | NEW |