| 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 gclient.py. | 6 """Unit tests for gclient.py. |
| 7 | 7 |
| 8 See gclient_smoketest.py for integration tests. | 8 See gclient_smoketest.py for integration tests. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 """Writes the content of a file and create the directories as needed.""" | 26 """Writes the content of a file and create the directories as needed.""" |
| 27 filename = os.path.abspath(filename) | 27 filename = os.path.abspath(filename) |
| 28 dirname = os.path.dirname(filename) | 28 dirname = os.path.dirname(filename) |
| 29 if not os.path.isdir(dirname): | 29 if not os.path.isdir(dirname): |
| 30 os.makedirs(dirname) | 30 os.makedirs(dirname) |
| 31 with open(filename, 'w') as f: | 31 with open(filename, 'w') as f: |
| 32 f.write(content) | 32 f.write(content) |
| 33 | 33 |
| 34 | 34 |
| 35 class SCMMock(object): | 35 class SCMMock(object): |
| 36 def __init__(self, unit_test, url): | 36 def __init__(self, unit_test, name, url): |
| 37 self.unit_test = unit_test | 37 self.unit_test = unit_test |
| 38 self.name = name |
| 38 self.url = url | 39 self.url = url |
| 39 | 40 |
| 40 def RunCommand(self, command, options, args, file_list): | 41 def RunCommand(self, command, options, args, file_list): |
| 41 self.unit_test.assertEquals('None', command) | 42 self.unit_test.assertEquals('None', command) |
| 42 self.unit_test.processed.put(self.url) | 43 self.unit_test.processed.put((self.name, self.url)) |
| 43 | 44 |
| 44 def FullUrlForRelativeUrl(self, url): | 45 def FullUrlForRelativeUrl(self, url): |
| 45 return self.url + url | 46 return self.url + url |
| 46 | 47 |
| 47 # pylint: disable=R0201 | 48 # pylint: disable=R0201 |
| 48 def DoesRemoteURLMatch(self, _): | 49 def DoesRemoteURLMatch(self, _): |
| 49 return True | 50 return True |
| 50 | 51 |
| 51 def GetActualRemoteURL(self, _): | 52 def GetActualRemoteURL(self, _): |
| 52 return self.url | 53 return self.url |
| (...skipping 15 matching lines...) Expand all Loading... |
| 68 def tearDown(self): | 69 def tearDown(self): |
| 69 self.assertEquals([], self._get_processed()) | 70 self.assertEquals([], self._get_processed()) |
| 70 gclient.gclient_scm.CreateSCM = self._old_createscm | 71 gclient.gclient_scm.CreateSCM = self._old_createscm |
| 71 sys.stdout = self._old_sys_stdout | 72 sys.stdout = self._old_sys_stdout |
| 72 os.chdir(self.previous_dir) | 73 os.chdir(self.previous_dir) |
| 73 super(GclientTest, self).tearDown() | 74 super(GclientTest, self).tearDown() |
| 74 | 75 |
| 75 def _createscm(self, parsed_url, root_dir, name, out_fh=None, out_cb=None): | 76 def _createscm(self, parsed_url, root_dir, name, out_fh=None, out_cb=None): |
| 76 self.assertTrue(parsed_url.startswith('svn://example.com/'), parsed_url) | 77 self.assertTrue(parsed_url.startswith('svn://example.com/'), parsed_url) |
| 77 self.assertTrue(root_dir.startswith(self.root_dir), root_dir) | 78 self.assertTrue(root_dir.startswith(self.root_dir), root_dir) |
| 78 return SCMMock(self, parsed_url) | 79 return SCMMock(self, name, parsed_url) |
| 79 | 80 |
| 80 def testDependencies(self): | 81 def testDependencies(self): |
| 81 self._dependencies('1') | 82 self._dependencies('1') |
| 82 | 83 |
| 83 def testDependenciesJobs(self): | 84 def testDependenciesJobs(self): |
| 84 self._dependencies('1000') | 85 self._dependencies('1000') |
| 85 | 86 |
| 86 def _dependencies(self, jobs): | 87 def _dependencies(self, jobs): |
| 87 """Verifies that dependencies are processed in the right order. | 88 """Verifies that dependencies are processed in the right order. |
| 88 | 89 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 # This foo/dir1/dir2 points to a different url than the one in bar. | 133 # This foo/dir1/dir2 points to a different url than the one in bar. |
| 133 ' "foo/dir1/dir2": "/dir1/another",\n' | 134 ' "foo/dir1/dir2": "/dir1/another",\n' |
| 134 '}') | 135 '}') |
| 135 | 136 |
| 136 obj = gclient.GClient.LoadCurrentConfig(options) | 137 obj = gclient.GClient.LoadCurrentConfig(options) |
| 137 self._check_requirements(obj.dependencies[0], {}) | 138 self._check_requirements(obj.dependencies[0], {}) |
| 138 self._check_requirements(obj.dependencies[1], {}) | 139 self._check_requirements(obj.dependencies[1], {}) |
| 139 obj.RunOnDeps('None', args) | 140 obj.RunOnDeps('None', args) |
| 140 actual = self._get_processed() | 141 actual = self._get_processed() |
| 141 first_3 = [ | 142 first_3 = [ |
| 142 'svn://example.com/bar', | 143 ('bar', 'svn://example.com/bar'), |
| 143 'svn://example.com/bar_empty', | 144 ('bar/empty', 'svn://example.com/bar_empty'), |
| 144 'svn://example.com/foo', | 145 ('foo', 'svn://example.com/foo'), |
| 145 ] | 146 ] |
| 146 if jobs != 1: | 147 if jobs != 1: |
| 147 # We don't care of the ordering of these items except that bar must be | 148 # We don't care of the ordering of these items except that bar must be |
| 148 # before bar/empty. | 149 # before bar/empty. |
| 149 self.assertTrue( | 150 self.assertTrue( |
| 150 actual.index('svn://example.com/bar') < | 151 actual.index(('bar', 'svn://example.com/bar')) < |
| 151 actual.index('svn://example.com/bar_empty')) | 152 actual.index(('bar/empty', 'svn://example.com/bar_empty'))) |
| 152 self.assertEquals(first_3, sorted(actual[0:3])) | 153 self.assertEquals(first_3, sorted(actual[0:3])) |
| 153 else: | 154 else: |
| 154 self.assertEquals(first_3, actual[0:3]) | 155 self.assertEquals(first_3, actual[0:3]) |
| 155 self.assertEquals( | 156 self.assertEquals( |
| 156 [ | 157 [ |
| 157 'svn://example.com/foo/dir1', | 158 ('foo/dir1', 'svn://example.com/foo/dir1'), |
| 158 'svn://example.com/bar/dir1/dir2', | 159 ('foo/dir1/dir2', 'svn://example.com/bar/dir1/dir2'), |
| 159 'svn://example.com/foo/dir1/dir2/dir3', | 160 ('foo/dir1/dir2/dir3', 'svn://example.com/foo/dir1/dir2/dir3'), |
| 160 'svn://example.com/foo/dir1/dir2/dir3/dir4', | 161 ('foo/dir1/dir2/dir3/dir4', |
| 161 'svn://example.com/foo/dir1/dir2/dir3/dir4/dir1/another', | 162 'svn://example.com/foo/dir1/dir2/dir3/dir4'), |
| 163 ('foo/dir1/dir2/dir5/dir6', |
| 164 'svn://example.com/foo/dir1/dir2/dir3/dir4/dir1/another'), |
| 162 ], | 165 ], |
| 163 actual[3:]) | 166 actual[3:]) |
| 164 | 167 |
| 165 self.assertEquals(3, len(obj.dependencies)) | 168 self.assertEquals(3, len(obj.dependencies)) |
| 166 self.assertEquals('foo', obj.dependencies[0].name) | 169 self.assertEquals('foo', obj.dependencies[0].name) |
| 167 self.assertEquals('bar', obj.dependencies[1].name) | 170 self.assertEquals('bar', obj.dependencies[1].name) |
| 168 self.assertEquals('bar/empty', obj.dependencies[2].name) | 171 self.assertEquals('bar/empty', obj.dependencies[2].name) |
| 169 self._check_requirements( | 172 self._check_requirements( |
| 170 obj.dependencies[0], | 173 obj.dependencies[0], |
| 171 { | 174 { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 471 |
| 469 parser = gclient.OptionParser() | 472 parser = gclient.OptionParser() |
| 470 options, _ = parser.parse_args(['--jobs', '1']) | 473 options, _ = parser.parse_args(['--jobs', '1']) |
| 471 options.deps_os = 'unix' | 474 options.deps_os = 'unix' |
| 472 | 475 |
| 473 obj = gclient.GClient.LoadCurrentConfig(options) | 476 obj = gclient.GClient.LoadCurrentConfig(options) |
| 474 obj.RunOnDeps('None', []) | 477 obj.RunOnDeps('None', []) |
| 475 self.assertEqual(['unix'], sorted(obj.enforced_os)) | 478 self.assertEqual(['unix'], sorted(obj.enforced_os)) |
| 476 self.assertEquals( | 479 self.assertEquals( |
| 477 [ | 480 [ |
| 478 'svn://example.com/bar', | 481 ('bar', 'svn://example.com/bar'), |
| 479 'svn://example.com/bar/unix', | 482 ('bar/unix', 'svn://example.com/bar/unix'), |
| 480 'svn://example.com/foo', | 483 ('foo', 'svn://example.com/foo'), |
| 481 'svn://example.com/foo/baz', | 484 ('foo/baz', 'svn://example.com/foo/baz'), |
| 482 'svn://example.com/foo/unix', | 485 ('foo/unix', 'svn://example.com/foo/unix'), |
| 483 ], | 486 ], |
| 484 sorted(self._get_processed())) | 487 sorted(self._get_processed())) |
| 485 | 488 |
| 486 def testUpdateWithOsDeps(self): | 489 def testUpdateWithOsDeps(self): |
| 487 """Verifies that complicated deps_os constructs result in the | 490 """Verifies that complicated deps_os constructs result in the |
| 488 correct data also with multple operating systems. Also see | 491 correct data also with multple operating systems. Also see |
| 489 testDepsOsOverrideDepsInDepsFile.""" | 492 testDepsOsOverrideDepsInDepsFile.""" |
| 490 | 493 |
| 491 test_data = [ | 494 test_data = [ |
| 492 # Tuples of deps, deps_os, os_list and expected_deps. | 495 # Tuples of deps, deps_os, os_list and expected_deps. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 599 |
| 597 parser = gclient.OptionParser() | 600 parser = gclient.OptionParser() |
| 598 options, _ = parser.parse_args(['--jobs', '1']) | 601 options, _ = parser.parse_args(['--jobs', '1']) |
| 599 options.deps_os = 'unix' | 602 options.deps_os = 'unix' |
| 600 | 603 |
| 601 obj = gclient.GClient.LoadCurrentConfig(options) | 604 obj = gclient.GClient.LoadCurrentConfig(options) |
| 602 obj.RunOnDeps('None', []) | 605 obj.RunOnDeps('None', []) |
| 603 self.assertEqual(['unix'], sorted(obj.enforced_os)) | 606 self.assertEqual(['unix'], sorted(obj.enforced_os)) |
| 604 self.assertEquals( | 607 self.assertEquals( |
| 605 [ | 608 [ |
| 606 'svn://example.com/foo', | 609 ('foo', 'svn://example.com/foo'), |
| 607 'svn://example.com/foo/baz', | 610 ('foo/baz', 'svn://example.com/foo/baz'), |
| 608 'svn://example.com/foo/src_unix', | 611 ('foo/src', 'svn://example.com/foo/src_unix'), |
| 609 'svn://example.com/foo/unix', | 612 ('foo/unix', 'svn://example.com/foo/unix'), |
| 610 ], | 613 ], |
| 611 sorted(self._get_processed())) | 614 sorted(self._get_processed())) |
| 612 | 615 |
| 613 def testRecursionOverride(self): | 616 def testRecursionOverride(self): |
| 614 """Verifies gclient respects the |recursion| var syntax. | 617 """Verifies gclient respects the |recursion| var syntax. |
| 615 | 618 |
| 616 We check several things here: | 619 We check several things here: |
| 617 - |recursion| = 3 sets recursion on the foo dep to exactly 3 | 620 - |recursion| = 3 sets recursion on the foo dep to exactly 3 |
| 618 (we pull /fizz, but not /fuzz) | 621 (we pull /fizz, but not /fuzz) |
| 619 - pulling foo/bar at recursion level 1 (in .gclient) is overriden by | 622 - pulling foo/bar at recursion level 1 (in .gclient) is overriden by |
| (...skipping 25 matching lines...) Expand all Loading... |
| 645 os.path.join('fizz', 'DEPS'), | 648 os.path.join('fizz', 'DEPS'), |
| 646 'deps = {\n' | 649 'deps = {\n' |
| 647 ' "fuzz": "/fuzz",\n' | 650 ' "fuzz": "/fuzz",\n' |
| 648 '}') | 651 '}') |
| 649 | 652 |
| 650 options, _ = gclient.OptionParser().parse_args([]) | 653 options, _ = gclient.OptionParser().parse_args([]) |
| 651 obj = gclient.GClient.LoadCurrentConfig(options) | 654 obj = gclient.GClient.LoadCurrentConfig(options) |
| 652 obj.RunOnDeps('None', []) | 655 obj.RunOnDeps('None', []) |
| 653 self.assertEquals( | 656 self.assertEquals( |
| 654 [ | 657 [ |
| 655 'svn://example.com/foo', | 658 ('foo', 'svn://example.com/foo'), |
| 656 'svn://example.com/bar', | 659 ('foo/bar', 'svn://example.com/bar'), |
| 657 'svn://example.com/foo/bar', | 660 ('bar', 'svn://example.com/foo/bar'), |
| 658 'svn://example.com/foo/bar/baz', | 661 ('baz', 'svn://example.com/foo/bar/baz'), |
| 659 'svn://example.com/foo/bar/baz/fizz', | 662 ('fizz', 'svn://example.com/foo/bar/baz/fizz'), |
| 660 ], | 663 ], |
| 661 self._get_processed()) | 664 self._get_processed()) |
| 662 | 665 |
| 663 def testRecursedepsOverride(self): | 666 def testRecursedepsOverride(self): |
| 664 """Verifies gclient respects the |recursedeps| var syntax. | 667 """Verifies gclient respects the |recursedeps| var syntax. |
| 665 | 668 |
| 666 This is what we mean to check here: | 669 This is what we mean to check here: |
| 667 - |recursedeps| = [...] on 2 levels means we pull exactly 3 deps | 670 - |recursedeps| = [...] on 2 levels means we pull exactly 3 deps |
| 668 (up to /fizz, but not /fuzz) | 671 (up to /fizz, but not /fuzz) |
| 669 - pulling foo/bar with no recursion (in .gclient) is overriden by | 672 - pulling foo/bar with no recursion (in .gclient) is overriden by |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 os.path.join('tar', 'DEPS'), | 707 os.path.join('tar', 'DEPS'), |
| 705 'deps = {\n' | 708 'deps = {\n' |
| 706 ' "taz": "/taz",\n' | 709 ' "taz": "/taz",\n' |
| 707 '}') | 710 '}') |
| 708 | 711 |
| 709 options, _ = gclient.OptionParser().parse_args([]) | 712 options, _ = gclient.OptionParser().parse_args([]) |
| 710 obj = gclient.GClient.LoadCurrentConfig(options) | 713 obj = gclient.GClient.LoadCurrentConfig(options) |
| 711 obj.RunOnDeps('None', []) | 714 obj.RunOnDeps('None', []) |
| 712 self.assertEquals( | 715 self.assertEquals( |
| 713 [ | 716 [ |
| 714 'svn://example.com/bar', | 717 ('bar', 'svn://example.com/foo/bar'), |
| 715 'svn://example.com/foo', | 718 ('baz', 'svn://example.com/foo/bar/baz'), |
| 716 'svn://example.com/foo/bar', | 719 ('fizz', 'svn://example.com/foo/bar/baz/fizz'), |
| 717 'svn://example.com/foo/bar/baz', | 720 ('foo', 'svn://example.com/foo'), |
| 718 'svn://example.com/foo/bar/baz/fizz', | 721 ('foo/bar', 'svn://example.com/bar'), |
| 719 'svn://example.com/tar', | 722 ('foo/tar', 'svn://example.com/tar'), |
| 720 ], | 723 ], |
| 721 sorted(self._get_processed())) | 724 sorted(self._get_processed())) |
| 722 | 725 |
| 723 def testRecursedepsOverrideWithRelativePaths(self): | 726 def testRecursedepsOverrideWithRelativePaths(self): |
| 724 """Verifies gclient respects |recursedeps| with relative paths.""" | 727 """Verifies gclient respects |recursedeps| with relative paths.""" |
| 725 | 728 |
| 726 write( | 729 write( |
| 727 '.gclient', | 730 '.gclient', |
| 728 'solutions = [\n' | 731 'solutions = [\n' |
| 729 ' { "name": "foo", "url": "svn://example.com/foo" },\n' | 732 ' { "name": "foo", "url": "svn://example.com/foo" },\n' |
| (...skipping 14 matching lines...) Expand all Loading... |
| 744 os.path.join('baz', 'DEPS'), | 747 os.path.join('baz', 'DEPS'), |
| 745 'deps = {\n' | 748 'deps = {\n' |
| 746 ' "fizz": "/fizz",\n' | 749 ' "fizz": "/fizz",\n' |
| 747 '}') | 750 '}') |
| 748 | 751 |
| 749 options, _ = gclient.OptionParser().parse_args([]) | 752 options, _ = gclient.OptionParser().parse_args([]) |
| 750 obj = gclient.GClient.LoadCurrentConfig(options) | 753 obj = gclient.GClient.LoadCurrentConfig(options) |
| 751 obj.RunOnDeps('None', []) | 754 obj.RunOnDeps('None', []) |
| 752 self.assertEquals( | 755 self.assertEquals( |
| 753 [ | 756 [ |
| 754 'svn://example.com/foo', | 757 ('foo', 'svn://example.com/foo'), |
| 755 # use_relative_paths means the following dep evaluates with 'foo' | 758 ('foo/bar', 'svn://example.com/foo/bar'), |
| 756 # prepended. | 759 # TODO(agable): Figure out why baz isn't included here. The |
| 757 'svn://example.com/foo/bar', | 760 # recursedeps = ["bar"] in foo's DEPS means that we should be |
| 761 # fetching the entries in bar's DEPS file, which includes baz. |
| 758 ], | 762 ], |
| 759 self._get_processed()) | 763 self._get_processed()) |
| 760 | 764 |
| 761 def testRecursionOverridesRecursedeps(self): | 765 def testRecursionOverridesRecursedeps(self): |
| 762 """Verifies gclient respects |recursion| over |recursedeps|. | 766 """Verifies gclient respects |recursion| over |recursedeps|. |
| 763 | 767 |
| 764 |recursion| is set in a top-level DEPS file. That value is meant | 768 |recursion| is set in a top-level DEPS file. That value is meant |
| 765 to affect how many subdeps are parsed via recursion. | 769 to affect how many subdeps are parsed via recursion. |
| 766 | 770 |
| 767 |recursedeps| is set in each DEPS file to control whether or not | 771 |recursedeps| is set in each DEPS file to control whether or not |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 os.path.join('fuzz', 'DEPS'), | 831 os.path.join('fuzz', 'DEPS'), |
| 828 'deps = {\n' | 832 'deps = {\n' |
| 829 ' "tar": "/tar",\n' | 833 ' "tar": "/tar",\n' |
| 830 '}') | 834 '}') |
| 831 | 835 |
| 832 options, _ = gclient.OptionParser().parse_args([]) | 836 options, _ = gclient.OptionParser().parse_args([]) |
| 833 obj = gclient.GClient.LoadCurrentConfig(options) | 837 obj = gclient.GClient.LoadCurrentConfig(options) |
| 834 obj.RunOnDeps('None', []) | 838 obj.RunOnDeps('None', []) |
| 835 self.assertEquals( | 839 self.assertEquals( |
| 836 [ | 840 [ |
| 837 'svn://example.com/foo', | 841 ('foo', 'svn://example.com/foo'), |
| 838 'svn://example.com/bar', | 842 ('foo/bar', 'svn://example.com/bar'), |
| 839 'svn://example.com/foo/bar', | 843 ('bar', 'svn://example.com/foo/bar'), |
| 840 # Deps after this would have been skipped if we were obeying | 844 # Deps after this would have been skipped if we were obeying |
| 841 # |recursedeps|. | 845 # |recursedeps|. |
| 842 'svn://example.com/foo/bar/baz', | 846 ('baz', 'svn://example.com/foo/bar/baz'), |
| 843 'svn://example.com/foo/bar/baz/fizz', | 847 ('fizz', 'svn://example.com/foo/bar/baz/fizz'), |
| 844 # And this dep would have been picked up if we were obeying | 848 # And this dep would have been picked up if we were obeying |
| 845 # |recursedeps|. | 849 # |recursedeps|. |
| 846 # 'svn://example.com/foo/bar/baz/fuzz', | 850 # 'svn://example.com/foo/bar/baz/fuzz', |
| 847 ], | 851 ], |
| 848 self._get_processed()) | 852 self._get_processed()) |
| 849 | 853 |
| 850 def testRecursedepsAltfile(self): | 854 def testRecursedepsAltfile(self): |
| 851 """Verifies gclient respects the |recursedeps| var syntax with overridden | 855 """Verifies gclient respects the |recursedeps| var syntax with overridden |
| 852 target DEPS file. | 856 target DEPS file. |
| 853 | 857 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 870 os.path.join('bar', 'DEPS.alt'), | 874 os.path.join('bar', 'DEPS.alt'), |
| 871 'deps = {\n' | 875 'deps = {\n' |
| 872 ' "baz": "/baz",\n' | 876 ' "baz": "/baz",\n' |
| 873 '}') | 877 '}') |
| 874 | 878 |
| 875 options, _ = gclient.OptionParser().parse_args([]) | 879 options, _ = gclient.OptionParser().parse_args([]) |
| 876 obj = gclient.GClient.LoadCurrentConfig(options) | 880 obj = gclient.GClient.LoadCurrentConfig(options) |
| 877 obj.RunOnDeps('None', []) | 881 obj.RunOnDeps('None', []) |
| 878 self.assertEquals( | 882 self.assertEquals( |
| 879 [ | 883 [ |
| 880 'svn://example.com/foo', | 884 ('foo', 'svn://example.com/foo'), |
| 881 'svn://example.com/foo/bar', | 885 ('bar', 'svn://example.com/foo/bar'), |
| 882 'svn://example.com/foo/bar/baz', | 886 ('baz', 'svn://example.com/foo/bar/baz'), |
| 883 ], | 887 ], |
| 884 self._get_processed()) | 888 self._get_processed()) |
| 885 | 889 |
| 886 def testGitDeps(self): | 890 def testGitDeps(self): |
| 887 """Verifies gclient respects a .DEPS.git deps file. | 891 """Verifies gclient respects a .DEPS.git deps file. |
| 888 | 892 |
| 889 Along the way, we also test that if both DEPS and .DEPS.git are present, | 893 Along the way, we also test that if both DEPS and .DEPS.git are present, |
| 890 that gclient does not read the DEPS file. This will reliably catch bugs | 894 that gclient does not read the DEPS file. This will reliably catch bugs |
| 891 where gclient is always hitting the wrong file (DEPS). | 895 where gclient is always hitting the wrong file (DEPS). |
| 892 """ | 896 """ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 906 os.path.join('foo', 'DEPS'), | 910 os.path.join('foo', 'DEPS'), |
| 907 'deps = {\n' | 911 'deps = {\n' |
| 908 ' "baz": "/baz",\n' | 912 ' "baz": "/baz",\n' |
| 909 '}') | 913 '}') |
| 910 | 914 |
| 911 options, _ = gclient.OptionParser().parse_args([]) | 915 options, _ = gclient.OptionParser().parse_args([]) |
| 912 obj = gclient.GClient.LoadCurrentConfig(options) | 916 obj = gclient.GClient.LoadCurrentConfig(options) |
| 913 obj.RunOnDeps('None', []) | 917 obj.RunOnDeps('None', []) |
| 914 self.assertEquals( | 918 self.assertEquals( |
| 915 [ | 919 [ |
| 916 'svn://example.com/foo', | 920 ('foo', 'svn://example.com/foo'), |
| 917 'svn://example.com/foo/bar', | 921 ('bar', 'svn://example.com/foo/bar'), |
| 918 ], | 922 ], |
| 919 self._get_processed()) | 923 self._get_processed()) |
| 920 | 924 |
| 921 def testGitDepsFallback(self): | 925 def testGitDepsFallback(self): |
| 922 """Verifies gclient respects fallback to DEPS upon missing deps file.""" | 926 """Verifies gclient respects fallback to DEPS upon missing deps file.""" |
| 923 write( | 927 write( |
| 924 '.gclient', | 928 '.gclient', |
| 925 'solutions = [\n' | 929 'solutions = [\n' |
| 926 ' { "name": "foo", "url": "svn://example.com/foo",\n' | 930 ' { "name": "foo", "url": "svn://example.com/foo",\n' |
| 927 ' "deps_file" : ".DEPS.git",\n' | 931 ' "deps_file" : ".DEPS.git",\n' |
| 928 ' },\n' | 932 ' },\n' |
| 929 ']') | 933 ']') |
| 930 write( | 934 write( |
| 931 os.path.join('foo', 'DEPS'), | 935 os.path.join('foo', 'DEPS'), |
| 932 'deps = {\n' | 936 'deps = {\n' |
| 933 ' "bar": "/bar",\n' | 937 ' "bar": "/bar",\n' |
| 934 '}') | 938 '}') |
| 935 | 939 |
| 936 options, _ = gclient.OptionParser().parse_args([]) | 940 options, _ = gclient.OptionParser().parse_args([]) |
| 937 obj = gclient.GClient.LoadCurrentConfig(options) | 941 obj = gclient.GClient.LoadCurrentConfig(options) |
| 938 obj.RunOnDeps('None', []) | 942 obj.RunOnDeps('None', []) |
| 939 self.assertEquals( | 943 self.assertEquals( |
| 940 [ | 944 [ |
| 941 'svn://example.com/foo', | 945 ('foo', 'svn://example.com/foo'), |
| 942 'svn://example.com/foo/bar', | 946 ('bar', 'svn://example.com/foo/bar'), |
| 943 ], | 947 ], |
| 944 self._get_processed()) | 948 self._get_processed()) |
| 945 | 949 |
| 946 def testDepsFromNotAllowedHostsUnspecified(self): | 950 def testDepsFromNotAllowedHostsUnspecified(self): |
| 947 """Verifies gclient works fine with DEPS without allowed_hosts.""" | 951 """Verifies gclient works fine with DEPS without allowed_hosts.""" |
| 948 write( | 952 write( |
| 949 '.gclient', | 953 '.gclient', |
| 950 'solutions = [\n' | 954 'solutions = [\n' |
| 951 ' { "name": "foo", "url": "svn://example.com/foo",\n' | 955 ' { "name": "foo", "url": "svn://example.com/foo",\n' |
| 952 ' "deps_file" : ".DEPS.git",\n' | 956 ' "deps_file" : ".DEPS.git",\n' |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 1070 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
| 1067 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 1071 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
| 1068 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 1072 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
| 1069 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 1073 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
| 1070 logging.basicConfig( | 1074 logging.basicConfig( |
| 1071 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 1075 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
| 1072 min(sys.argv.count('-v'), 3)], | 1076 min(sys.argv.count('-v'), 3)], |
| 1073 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 1077 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
| 1074 '%(lineno)d) %(message)s') | 1078 '%(lineno)d) %(message)s') |
| 1075 unittest.main() | 1079 unittest.main() |
| OLD | NEW |