| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 'Node Kind': 'file', | 422 'Node Kind': 'file', |
| 423 'Path': 'chromeos/views/webui_menu_widget.h', | 423 'Path': 'chromeos/views/webui_menu_widget.h', |
| 424 'Repository Root': '%s' % self.svn_base.rstrip('/'), | 424 'Repository Root': '%s' % self.svn_base.rstrip('/'), |
| 425 'Revision': '2', | 425 'Revision': '2', |
| 426 'Schedule': 'add', | 426 'Schedule': 'add', |
| 427 'URL': '%strunk/chromeos/views/webui_menu_widget.h' % self.svn_base, | 427 'URL': '%strunk/chromeos/views/webui_menu_widget.h' % self.svn_base, |
| 428 } | 428 } |
| 429 self.assertEquals(expected, values) | 429 self.assertEquals(expected, values) |
| 430 | 430 |
| 431 | 431 |
| 432 class GitSvnCheckout(SvnBaseTest): | |
| 433 name = 'foo.git' | |
| 434 | |
| 435 def _get_co(self, post_processors): | |
| 436 self.assertNotEqual(False, post_processors) | |
| 437 return checkout.GitSvnCheckout( | |
| 438 self.root_dir, self.name[:-4], | |
| 439 self.usr, self.pwd, | |
| 440 self.svn_base, self.svn_trunk, post_processors) | |
| 441 | |
| 442 def testAll(self): | |
| 443 expected = { | |
| 444 'author': self.FAKE_REPOS.USERS[0][0], | |
| 445 } | |
| 446 root = os.path.join(self.root_dir, self.name) | |
| 447 self._check_base(self._get_co(None), root, True, expected) | |
| 448 | |
| 449 def testGitSvnPremade(self): | |
| 450 # Test premade git-svn clone. First make a git-svn clone. | |
| 451 git_svn_co = self._get_co(None) | |
| 452 revision = git_svn_co.prepare(None) | |
| 453 self.assertEquals(self.previous_log['revision'], revision) | |
| 454 # Then use GitSvnClone to clone it to lose the git-svn connection and verify | |
| 455 # git svn init / git svn fetch works. | |
| 456 git_svn_clone = checkout.GitSvnPremadeCheckout( | |
| 457 self.root_dir, self.name[:-4] + '2', 'trunk', | |
| 458 self.usr, self.pwd, | |
| 459 self.svn_base, self.svn_trunk, git_svn_co.project_path) | |
| 460 self.assertEquals( | |
| 461 self.previous_log['revision'], git_svn_clone.prepare(None)) | |
| 462 | |
| 463 def testException(self): | |
| 464 self._check_exception( | |
| 465 self._get_co(None), 'fatal: corrupt patch at line 12\n') | |
| 466 | |
| 467 def testSvnProps(self): | |
| 468 co = self._get_co(None) | |
| 469 co.prepare(None) | |
| 470 try: | |
| 471 svn_props = [('foo', 'bar')] | |
| 472 co.apply_patch( | |
| 473 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) | |
| 474 self.fail() | |
| 475 except patch.UnsupportedPatchFormat, e: | |
| 476 self.assertEquals(e.filename, 'chrome/file.cc') | |
| 477 self.assertEquals( | |
| 478 e.status, | |
| 479 'Cannot apply svn property foo to file chrome/file.cc.') | |
| 480 co.prepare(None) | |
| 481 # svn:eol-style is ignored. | |
| 482 svn_props = [('svn:eol-style', 'LF')] | |
| 483 co.apply_patch( | |
| 484 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) | |
| 485 | |
| 486 def testProcess(self): | |
| 487 self._test_process(self._get_co) | |
| 488 | |
| 489 def testPrepare(self): | |
| 490 co = self._get_co(None) | |
| 491 # TODO(maruel): Cheat here until prepare(revision != None) implemented. | |
| 492 co.old_prepare = co.prepare | |
| 493 def prepare(rev): | |
| 494 # Basically, test that it is broken. | |
| 495 self.assertEquals(1, rev) | |
| 496 self.assertEquals(2, co.old_prepare(None)) | |
| 497 return 1 | |
| 498 co.prepare = prepare | |
| 499 self._test_prepare(co) | |
| 500 | |
| 501 def testMove(self): | |
| 502 self._check_move(self._get_co(None)) | |
| 503 | |
| 504 | |
| 505 class RawCheckout(SvnBaseTest): | 432 class RawCheckout(SvnBaseTest): |
| 506 def setUp(self): | 433 def setUp(self): |
| 507 super(RawCheckout, self).setUp() | 434 super(RawCheckout, self).setUp() |
| 508 # Use a svn checkout as the base. | 435 # Use a svn checkout as the base. |
| 509 self.base_co = checkout.SvnCheckout( | 436 self.base_co = checkout.SvnCheckout( |
| 510 self.root_dir, self.name, None, None, self.svn_url) | 437 self.root_dir, self.name, None, None, self.svn_url) |
| 511 self.base_co.prepare(None) | 438 self.base_co.prepare(None) |
| 512 | 439 |
| 513 def _get_co(self, post_processors): | 440 def _get_co(self, post_processors): |
| 514 self.assertNotEqual(False, post_processors) | 441 self.assertNotEqual(False, post_processors) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 if '-v' in sys.argv: | 533 if '-v' in sys.argv: |
| 607 DEBUGGING = True | 534 DEBUGGING = True |
| 608 logging.basicConfig( | 535 logging.basicConfig( |
| 609 level=logging.DEBUG, | 536 level=logging.DEBUG, |
| 610 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 537 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
| 611 else: | 538 else: |
| 612 logging.basicConfig( | 539 logging.basicConfig( |
| 613 level=logging.ERROR, | 540 level=logging.ERROR, |
| 614 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 541 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
| 615 unittest.main() | 542 unittest.main() |
| OLD | NEW |