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