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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 tree['src/git_hooked1'] = 'git_hooked1' | 1172 tree['src/git_hooked1'] = 'git_hooked1' |
1173 tree['src/git_hooked2'] = 'git_hooked2' | 1173 tree['src/git_hooked2'] = 'git_hooked2' |
1174 self.assertTree(tree) | 1174 self.assertTree(tree) |
1175 | 1175 |
1176 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1']) | 1176 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1']) |
1177 out = results[0].splitlines(False) | 1177 out = results[0].splitlines(False) |
1178 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 1178 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
1179 # files. | 1179 # files. |
1180 self.assertEquals(0, len(out)) | 1180 self.assertEquals(0, len(out)) |
1181 | 1181 |
1182 def testSyncNoHistory(self): | |
1183 if not self.enabled: | |
1184 return | |
1185 # Create an extra commit in repo_2 and point DEPS to its hash. | |
1186 cur_deps = self.FAKE_REPOS.git_hashes['repo_1'][-1][1]['DEPS'] | |
1187 repo_2_hash_old = self.FAKE_REPOS.git_hashes['repo_2'][1][0][:7] | |
1188 self.FAKE_REPOS._commit_git('repo_2', { # pylint: disable=W0212 | |
1189 'last_file': 'file created in last commit', | |
1190 }) | |
1191 repo_2_hash_new = self.FAKE_REPOS.git_hashes['repo_2'][-1][0] | |
1192 new_deps = cur_deps.replace(repo_2_hash_old, repo_2_hash_new) | |
1193 self.assertNotEqual(new_deps, cur_deps) | |
1194 self.FAKE_REPOS._commit_git('repo_1', { # pylint: disable=W0212 | |
1195 'DEPS': new_deps, | |
1196 'origin': 'git/repo_1@4\n', | |
1197 }) | |
1198 | |
1199 config_template = ( | |
1200 """solutions = [{ | |
1201 "name" : "src", | |
1202 "url" : "%(git_base)srepo_1", | |
1203 "deps_file" : "DEPS", | |
1204 "managed" : True, | |
1205 }]""") | |
1206 | |
1207 self.gclient(['config', '--spec', config_template % { | |
1208 'git_base': self.git_base | |
1209 }]) | |
1210 | |
1211 self.gclient(['sync', '--no-history', '--deps', 'mac']) | |
1212 repo2_root = join(self.root_dir, 'src', 'repo2') | |
1213 | |
1214 # Check that repo_2 is actually shallow and its log has only one entry. | |
1215 rev_lists = subprocess2.check_output(['git', 'rev-list', 'HEAD'], | |
1216 cwd=repo2_root) | |
1217 self.assertEquals(repo_2_hash_new, rev_lists.strip('\r\n')) | |
1218 | |
1219 # Check that we have actually checked out the right commit. | |
1220 self.assertTrue(os.path.exists(join(repo2_root, 'last_file'))) | |
1221 | |
1222 | |
1223 class GClientSmokeBoth(GClientSmokeBase): | 1182 class GClientSmokeBoth(GClientSmokeBase): |
1224 def setUp(self): | 1183 def setUp(self): |
1225 super(GClientSmokeBoth, self).setUp() | 1184 super(GClientSmokeBoth, self).setUp() |
1226 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git() | 1185 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git() |
1227 | 1186 |
1228 def testMultiSolutions(self): | 1187 def testMultiSolutions(self): |
1229 if not self.enabled: | 1188 if not self.enabled: |
1230 return | 1189 return |
1231 self.gclient(['config', '--spec', | 1190 self.gclient(['config', '--spec', |
1232 'solutions=[' | 1191 'solutions=[' |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 | 1597 |
1639 if '-c' in sys.argv: | 1598 if '-c' in sys.argv: |
1640 COVERAGE = True | 1599 COVERAGE = True |
1641 sys.argv.remove('-c') | 1600 sys.argv.remove('-c') |
1642 if os.path.exists('.coverage'): | 1601 if os.path.exists('.coverage'): |
1643 os.remove('.coverage') | 1602 os.remove('.coverage') |
1644 os.environ['COVERAGE_FILE'] = os.path.join( | 1603 os.environ['COVERAGE_FILE'] = os.path.join( |
1645 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1604 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1646 '.coverage') | 1605 '.coverage') |
1647 unittest.main() | 1606 unittest.main() |
OLD | NEW |