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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 co = self._get_co(None) | 508 co = self._get_co(None) |
509 co.prepare(None) | 509 co.prepare(None) |
510 try: | 510 try: |
511 # svn:ignore can only be applied to directories. | 511 # svn:ignore can only be applied to directories. |
512 svn_props = [('svn:ignore', 'foo')] | 512 svn_props = [('svn:ignore', 'foo')] |
513 co.apply_patch( | 513 co.apply_patch( |
514 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) | 514 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) |
515 self.fail() | 515 self.fail() |
516 except checkout.PatchApplicationFailed, e: | 516 except checkout.PatchApplicationFailed, e: |
517 self.assertEquals(e.filename, 'chrome/file.cc') | 517 self.assertEquals(e.filename, 'chrome/file.cc') |
518 self.assertEquals( | 518 # The last line of the output depends on the svn version so we can't |
| 519 # check it precisely |
| 520 self.assertRegexpMatches( |
519 e.status, | 521 e.status, |
520 'While running svn propset svn:ignore foo chrome/file.cc ' | 522 'While running svn propset svn:ignore foo chrome/file.cc ' |
521 '--non-interactive;\n' | 523 '--non-interactive;\n' |
522 ' patching file chrome/file.cc\n' | 524 ' patching file chrome/file.cc\n' |
523 ' svn: Cannot set \'svn:ignore\' on a file (\'chrome/file.cc\')\n') | 525 ' svn:.*') |
524 co.prepare(None) | 526 co.prepare(None) |
525 svn_props = [('svn:eol-style', 'LF'), ('foo', 'bar')] | 527 svn_props = [('svn:eol-style', 'LF'), ('foo', 'bar')] |
526 co.apply_patch( | 528 co.apply_patch( |
527 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) | 529 [patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, svn_props)]) |
528 filepath = os.path.join(self.root_dir, self.name, 'chrome/file.cc') | 530 filepath = os.path.join(self.root_dir, self.name, 'chrome/file.cc') |
529 # Manually verify the properties. | 531 # Manually verify the properties. |
530 props = subprocess2.check_output( | 532 props = subprocess2.check_output( |
531 ['svn', 'proplist', filepath], | 533 ['svn', 'proplist', filepath], |
532 cwd=self.root_dir).splitlines()[1:] | 534 cwd=self.root_dir).splitlines()[1:] |
533 props = sorted(p.strip() for p in props) | 535 props = sorted(p.strip() for p in props) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 self.assertEquals(expected, out) | 603 self.assertEquals(expected, out) |
602 # Make sure ancestry is what is expected; | 604 # Make sure ancestry is what is expected; |
603 env = os.environ.copy() | 605 env = os.environ.copy() |
604 env['LANGUAGE'] = 'en_US.UTF-8' | 606 env['LANGUAGE'] = 'en_US.UTF-8' |
605 out = subprocess2.check_output( | 607 out = subprocess2.check_output( |
606 ['svn', 'info', 'chromeos/views/webui_menu_widget.h'], | 608 ['svn', 'info', 'chromeos/views/webui_menu_widget.h'], |
607 cwd=co.project_path, | 609 cwd=co.project_path, |
608 env=env) | 610 env=env) |
609 values = dict(l.split(': ', 1) for l in out.splitlines() if l) | 611 values = dict(l.split(': ', 1) for l in out.splitlines() if l) |
610 expected = { | 612 expected = { |
611 'Checksum': '65837bb3da662c8fa88a4a50940ea7c6', | 613 # checksum seems to vary with svn version so we can't check it |
| 614 #'Checksum': '65837bb3da662c8fa88a4a50940ea7c6', |
612 'Copied From Rev': '2', | 615 'Copied From Rev': '2', |
613 'Copied From URL': | 616 'Copied From URL': |
614 '%strunk/chromeos/views/DOMui_menu_widget.h' % self.svn_base, | 617 '%strunk/chromeos/views/DOMui_menu_widget.h' % self.svn_base, |
615 'Name': 'webui_menu_widget.h', | 618 'Name': 'webui_menu_widget.h', |
616 'Node Kind': 'file', | 619 'Node Kind': 'file', |
617 'Path': 'chromeos/views/webui_menu_widget.h', | 620 'Path': 'chromeos/views/webui_menu_widget.h', |
618 'Repository Root': '%s' % self.svn_base.rstrip('/'), | 621 'Repository Root': '%s' % self.svn_base.rstrip('/'), |
619 'Revision': '2', | 622 'Revision': '2', |
620 'Schedule': 'add', | 623 'Schedule': 'add', |
621 'URL': '%strunk/chromeos/views/webui_menu_widget.h' % self.svn_base, | 624 'URL': '%strunk/chromeos/views/webui_menu_widget.h' % self.svn_base, |
622 } | 625 } |
623 self.assertEquals(expected, values) | 626 for key in expected: |
| 627 self.assertIn(key, values) |
| 628 self.assertEquals(expected[key], values[key]) |
624 | 629 |
625 | 630 |
626 class RawCheckout(SvnBaseTest): | 631 class RawCheckout(SvnBaseTest): |
627 def setUp(self): | 632 def setUp(self): |
628 super(RawCheckout, self).setUp() | 633 super(RawCheckout, self).setUp() |
629 # Use a svn checkout as the base. | 634 # Use a svn checkout as the base. |
630 self.base_co = checkout.SvnCheckout( | 635 self.base_co = checkout.SvnCheckout( |
631 self.root_dir, self.name, None, None, self.svn_url) | 636 self.root_dir, self.name, None, None, self.svn_url) |
632 self.base_co.prepare(None) | 637 self.base_co.prepare(None) |
633 | 638 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 if '-v' in sys.argv: | 733 if '-v' in sys.argv: |
729 DEBUGGING = True | 734 DEBUGGING = True |
730 logging.basicConfig( | 735 logging.basicConfig( |
731 level=logging.DEBUG, | 736 level=logging.DEBUG, |
732 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 737 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
733 else: | 738 else: |
734 logging.basicConfig( | 739 logging.basicConfig( |
735 level=logging.ERROR, | 740 level=logging.ERROR, |
736 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 741 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
737 unittest.main() | 742 unittest.main() |
OLD | NEW |