| 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 """Smoke tests for gclient.py. | 6 """Smoke tests for gclient.py. |
| 7 | 7 |
| 8 Shell out 'gclient' and run basic conformance tests. | 8 Shell out 'gclient' and run basic conformance tests. |
| 9 | 9 |
| 10 This test assumes GClientSmokeBase.URL_BASE is valid. | 10 This test assumes GClientSmokeBase.URL_BASE is valid. |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 ('repo_3@1', 'src/repo2/repo3'), | 996 ('repo_3@1', 'src/repo2/repo3'), |
| 997 ('repo_3@2', 'src/repo2/repo_renamed'), | 997 ('repo_3@2', 'src/repo2/repo_renamed'), |
| 998 ('repo_4@2', 'src/repo4')) | 998 ('repo_4@2', 'src/repo4')) |
| 999 tree['src/git_hooked1'] = 'git_hooked1' | 999 tree['src/git_hooked1'] = 'git_hooked1' |
| 1000 tree['src/git_hooked2'] = 'git_hooked2' | 1000 tree['src/git_hooked2'] = 'git_hooked2' |
| 1001 self.assertTree(tree) | 1001 self.assertTree(tree) |
| 1002 | 1002 |
| 1003 def testRevertAndStatus(self): | 1003 def testRevertAndStatus(self): |
| 1004 if not self.enabled: | 1004 if not self.enabled: |
| 1005 return | 1005 return |
| 1006 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 1006 |
| 1007 # Commit new change to repo to make repo_2's hash use a custom_var. |
| 1008 cur_deps = self.FAKE_REPOS.git_hashes['repo_1'][-1][1]['DEPS'] |
| 1009 repo_2_hash = self.FAKE_REPOS.git_hashes['repo_2'][1][0][:7] |
| 1010 new_deps = cur_deps.replace('repo_2@%s\'' % repo_2_hash, |
| 1011 'repo_2@\' + Var(\'r2hash\')') |
| 1012 new_deps = 'vars = {\'r2hash\': \'%s\'}\n%s' % (repo_2_hash, new_deps) |
| 1013 self.FAKE_REPOS._commit_git('repo_1', { # pylint: disable=W0212 |
| 1014 'DEPS': new_deps, |
| 1015 'origin': 'git/repo_1@3\n', |
| 1016 }) |
| 1017 |
| 1018 config_template = ( |
| 1019 """solutions = [{ |
| 1020 "name" : "src", |
| 1021 "url" : "%(git_base)srepo_1", |
| 1022 "deps_file" : "DEPS", |
| 1023 "managed" : True, |
| 1024 "custom_vars" : %(custom_vars)s, |
| 1025 }]""") |
| 1026 |
| 1027 self.gclient(['config', '--spec', config_template % { |
| 1028 'git_base': self.git_base, |
| 1029 'custom_vars': {} |
| 1030 }]) |
| 1031 |
| 1007 # Tested in testSync. | 1032 # Tested in testSync. |
| 1008 self.gclient(['sync', '--deps', 'mac']) | 1033 self.gclient(['sync', '--deps', 'mac']) |
| 1009 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') | 1034 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') |
| 1010 | 1035 |
| 1011 expected1 = ('running', os.path.join(self.root_dir, 'src')) | 1036 expected1 = ('running', os.path.join(self.root_dir, 'src')) |
| 1012 expected2 = ('running', os.path.join(expected1[1], 'repo2')) | 1037 expected2 = ('running', os.path.join(expected1[1], 'repo2')) |
| 1013 expected3 = ('running', os.path.join(expected2[1], 'repo_renamed')) | 1038 expected3 = ('running', os.path.join(expected2[1], 'repo_renamed')) |
| 1014 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], | 1039 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], |
| 1015 [expected1, expected2, expected3]) | 1040 [expected1, expected2, expected3]) |
| 1016 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 1041 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
| 1017 # files. | 1042 # files. |
| 1018 self.assertEquals(3, len(out)) | 1043 self.assertEquals(3, len(out)) |
| 1019 | 1044 |
| 1020 # Revert implies --force implies running hooks without looking at pattern | 1045 # Revert implies --force implies running hooks without looking at pattern |
| 1021 # matching. For each expected path, 'git reset' and 'git clean' are run, so | 1046 # matching. For each expected path, 'git reset' and 'git clean' are run, so |
| 1022 # there should be two results for each. The last two results should reflect | 1047 # there should be two results for each. The last two results should reflect |
| 1023 # writing git_hooked1 and git_hooked2. | 1048 # writing git_hooked1 and git_hooked2. |
| 1024 expected4 = ('running', self.root_dir) | 1049 expected4 = ('running', self.root_dir) |
| 1025 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], | 1050 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], |
| 1026 [expected1, expected1, | 1051 [expected1, expected1, |
| 1027 expected2, expected2, | 1052 expected2, expected2, |
| 1028 expected3, expected3, | 1053 expected3, expected3, |
| 1029 expected4, expected4]) | 1054 expected4, expected4]) |
| 1030 self.assertEquals(8, len(out)) | 1055 self.assertEquals(8, len(out)) |
| 1031 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 1056 tree = self.mangle_git_tree(('repo_1@3', 'src'), |
| 1032 ('repo_2@1', 'src/repo2'), | 1057 ('repo_2@1', 'src/repo2'), |
| 1033 ('repo_3@2', 'src/repo2/repo_renamed')) | 1058 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 1034 tree['src/git_hooked1'] = 'git_hooked1' | 1059 tree['src/git_hooked1'] = 'git_hooked1' |
| 1035 tree['src/git_hooked2'] = 'git_hooked2' | 1060 tree['src/git_hooked2'] = 'git_hooked2' |
| 1036 self.assertTree(tree) | 1061 self.assertTree(tree) |
| 1037 | 1062 |
| 1063 # Make a new commit object in the origin repo, to force reset to fetch. |
| 1064 self.FAKE_REPOS._commit_git('repo_2', { # pylint: disable=W0212 |
| 1065 'origin': 'git/repo_2@3\n', |
| 1066 }) |
| 1067 |
| 1068 self.gclient(['config', '--spec', config_template % { |
| 1069 'git_base': self.git_base, |
| 1070 'custom_vars': {'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0] } |
| 1071 }]) |
| 1072 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], |
| 1073 [expected1, expected1, |
| 1074 expected2, expected2, |
| 1075 expected3, expected3, |
| 1076 expected4, expected4]) |
| 1077 self.assertEquals(8, len(out)) |
| 1078 tree = self.mangle_git_tree(('repo_1@3', 'src'), |
| 1079 ('repo_2@3', 'src/repo2'), |
| 1080 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 1081 tree['src/git_hooked1'] = 'git_hooked1' |
| 1082 tree['src/git_hooked2'] = 'git_hooked2' |
| 1083 self.assertTree(tree) |
| 1084 |
| 1038 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1']) | 1085 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1']) |
| 1039 out = results[0].splitlines(False) | 1086 out = results[0].splitlines(False) |
| 1040 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 1087 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
| 1041 # files. | 1088 # files. |
| 1042 self.assertEquals(6, len(out)) | 1089 self.assertEquals(6, len(out)) |
| 1043 | 1090 |
| 1044 def testRunHooks(self): | 1091 def testRunHooks(self): |
| 1045 if not self.enabled: | 1092 if not self.enabled: |
| 1046 return | 1093 return |
| 1047 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 1094 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1491 |
| 1445 if '-c' in sys.argv: | 1492 if '-c' in sys.argv: |
| 1446 COVERAGE = True | 1493 COVERAGE = True |
| 1447 sys.argv.remove('-c') | 1494 sys.argv.remove('-c') |
| 1448 if os.path.exists('.coverage'): | 1495 if os.path.exists('.coverage'): |
| 1449 os.remove('.coverage') | 1496 os.remove('.coverage') |
| 1450 os.environ['COVERAGE_FILE'] = os.path.join( | 1497 os.environ['COVERAGE_FILE'] = os.path.join( |
| 1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1498 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 1452 '.coverage') | 1499 '.coverage') |
| 1453 unittest.main() | 1500 unittest.main() |
| OLD | NEW |