OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ) | 170 ) |
171 self.assertTree(tree) | 171 self.assertTree(tree) |
172 # Test incremental sync: delete-unversioned_trees isn't there. | 172 # Test incremental sync: delete-unversioned_trees isn't there. |
173 results = self.gclient(['sync', '--deps', 'mac']) | 173 results = self.gclient(['sync', '--deps', 'mac']) |
174 logging.debug(results[0]) | 174 logging.debug(results[0]) |
175 out = results[0].splitlines(False) | 175 out = results[0].splitlines(False) |
176 self.assertEquals(21, len(out)) | 176 self.assertEquals(21, len(out)) |
177 self.checkString('', results[1]) | 177 self.checkString('', results[1]) |
178 self.assertEquals(0, results[2]) | 178 self.assertEquals(0, results[2]) |
179 tree = mangle_svn_tree( | 179 tree = mangle_svn_tree( |
180 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[-1]), | 180 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]), |
181 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 181 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), |
182 self.FAKE_REPOS.svn_revs[2]), | 182 self.FAKE_REPOS.svn_revs[2]), |
183 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 183 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), |
184 self.FAKE_REPOS.svn_revs[1]), | 184 self.FAKE_REPOS.svn_revs[1]), |
185 (join('trunk', 'other'), join('src', 'other'), | 185 (join('trunk', 'other'), join('src', 'other'), |
186 self.FAKE_REPOS.svn_revs[2]), | 186 self.FAKE_REPOS.svn_revs[2]), |
187 (join('trunk', 'third_party', 'foo'), | 187 (join('trunk', 'third_party', 'foo'), |
188 join('src', 'third_party', 'prout'), | 188 join('src', 'third_party', 'prout'), |
189 self.FAKE_REPOS.svn_revs[2]), | 189 self.FAKE_REPOS.svn_revs[2]), |
190 ) | 190 ) |
191 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' | 191 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' |
192 self.assertTree(tree) | 192 self.assertTree(tree) |
193 | 193 |
194 def SyncAtRev1(self, arg): | 194 def testSyncIgnoredSolutionName(self): |
| 195 """TODO(maruel): This will become an error soon.""" |
195 self.gclient(['config', self.svn_base + 'trunk/src/']) | 196 self.gclient(['config', self.svn_base + 'trunk/src/']) |
196 results = self.gclient(['sync', '--deps', 'mac', '-r', arg]) | 197 results = self.gclient(['sync', '--deps', 'mac', '-r', 'invalid@1']) |
| 198 out = results[0].splitlines(False) |
| 199 self.assertEquals(17, len(out)) |
| 200 self.checkString('Please fix your script, having invalid --revision flags ' |
| 201 'will soon considered an error.\n', results[1]) |
| 202 self.assertEquals(0, results[2]) |
| 203 tree = mangle_svn_tree( |
| 204 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]), |
| 205 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), |
| 206 self.FAKE_REPOS.svn_revs[1]), |
| 207 (join('trunk', 'other'), join('src', 'other'), |
| 208 self.FAKE_REPOS.svn_revs[2]), |
| 209 ) |
| 210 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' |
| 211 self.assertTree(tree) |
| 212 |
| 213 def testSyncNoSolutionName(self): |
| 214 # When no solution name is provided, gclient uses the first solution listed. |
| 215 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 216 results = self.gclient(['sync', '--deps', 'mac', '-r', '1']) |
197 out = results[0].splitlines(False) | 217 out = results[0].splitlines(False) |
198 self.assertEquals(19, len(out)) | 218 self.assertEquals(19, len(out)) |
199 self.checkString('', results[1]) | 219 self.checkString('', results[1]) |
200 self.assertEquals(0, results[2]) | 220 self.assertEquals(0, results[2]) |
201 tree = mangle_svn_tree( | 221 tree = mangle_svn_tree( |
202 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]), | 222 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]), |
203 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 223 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), |
204 self.FAKE_REPOS.svn_revs[2]), | 224 self.FAKE_REPOS.svn_revs[2]), |
205 (join('trunk', 'other'), join('src', 'other'), | 225 (join('trunk', 'other'), join('src', 'other'), |
206 self.FAKE_REPOS.svn_revs[2]), | 226 self.FAKE_REPOS.svn_revs[2]), |
207 (join('trunk', 'third_party', 'foo'), | 227 (join('trunk', 'third_party', 'foo'), |
208 join('src', 'third_party', 'prout'), | 228 join('src', 'third_party', 'prout'), |
209 self.FAKE_REPOS.svn_revs[2]), | 229 self.FAKE_REPOS.svn_revs[2]), |
210 ) | 230 ) |
211 self.assertTree(tree) | 231 self.assertTree(tree) |
212 | 232 |
213 def testSyncIgnoredSolutionName(self): | |
214 self.SyncAtRev1('ignored@1') | |
215 | |
216 def testSyncNoSolutionName(self): | |
217 self.SyncAtRev1('1') | |
218 | |
219 def testRevertAndStatus(self): | 233 def testRevertAndStatus(self): |
220 self.gclient(['config', self.svn_base + 'trunk/src/']) | 234 self.gclient(['config', self.svn_base + 'trunk/src/']) |
221 # Tested in testSync. | 235 # Tested in testSync. |
222 self.gclient(['sync', '--deps', 'mac']) | 236 self.gclient(['sync', '--deps', 'mac']) |
223 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') | 237 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') |
224 | 238 |
225 results = self.gclient(['status']) | 239 results = self.gclient(['status']) |
226 out = results[0].splitlines(False) | 240 out = results[0].splitlines(False) |
227 self.assertEquals(out[0], '') | 241 self.assertEquals(out[0], '') |
228 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) | 242 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 (join('src', 'repo2', 'repo3'), | 427 (join('src', 'repo2', 'repo3'), |
414 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | 428 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
415 (join('src', 'repo2', 'repo_renamed'), | 429 (join('src', 'repo2', 'repo_renamed'), |
416 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | 430 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
417 (join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]), | 431 (join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]), |
418 ) | 432 ) |
419 tree[join('src', 'git_hooked1')] = 'git_hooked1' | 433 tree[join('src', 'git_hooked1')] = 'git_hooked1' |
420 tree[join('src', 'git_hooked2')] = 'git_hooked2' | 434 tree[join('src', 'git_hooked2')] = 'git_hooked2' |
421 self.assertTree(tree) | 435 self.assertTree(tree) |
422 | 436 |
| 437 def testSyncIgnoredSolutionName(self): |
| 438 """TODO(maruel): This will become an error soon.""" |
| 439 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 440 results = self.gclient([ |
| 441 'sync', '--deps', 'mac', '--revision', |
| 442 'invalid@' + self.FAKE_REPOS.git_hashes['repo_1'][0][0], |
| 443 ]) |
| 444 out = results[0].splitlines(False) |
| 445 |
| 446 self.assertEquals(13, len(out)) |
| 447 # TODO(maruel): git shouldn't output to stderr... |
| 448 self.checkString('Please fix your script, having invalid --revision flags ' |
| 449 'will soon considered an error.\nSwitched to a new branch \'%s\'\n' % |
| 450 self.FAKE_REPOS.git_hashes['repo_2'][0][0][:7], |
| 451 results[1]) |
| 452 self.assertEquals(0, results[2]) |
| 453 tree = mangle_git_tree( |
| 454 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), |
| 455 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]), |
| 456 (join('src', 'repo2', 'repo_renamed'), |
| 457 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 458 ) |
| 459 tree[join('src', 'git_hooked1')] = 'git_hooked1' |
| 460 tree[join('src', 'git_hooked2')] = 'git_hooked2' |
| 461 self.assertTree(tree) |
| 462 |
| 463 def testSyncNoSolutionName(self): |
| 464 # When no solution name is provided, gclient uses the first solution listed. |
| 465 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 466 results = self.gclient([ |
| 467 'sync', '--deps', 'mac', '--revision', |
| 468 self.FAKE_REPOS.git_hashes['repo_1'][0][0], |
| 469 ]) |
| 470 out = results[0].splitlines(False) |
| 471 self.assertEquals(12, len(out)) |
| 472 # TODO(maruel): git shouldn't output to stderr... |
| 473 self.checkString('Switched to a new branch \'%s\'\n' |
| 474 % self.FAKE_REPOS.git_hashes['repo_1'][0][0], results[1]) |
| 475 self.assertEquals(0, results[2]) |
| 476 tree = mangle_git_tree( |
| 477 ('src', self.FAKE_REPOS.git_hashes['repo_1'][0][1]), |
| 478 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]), |
| 479 (join('src', 'repo2', 'repo3'), |
| 480 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 481 (join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]), |
| 482 ) |
| 483 self.assertTree(tree) |
| 484 |
423 def testRevertAndStatus(self): | 485 def testRevertAndStatus(self): |
424 """TODO(maruel): Remove this line once this test is fixed.""" | 486 """TODO(maruel): Remove this line once this test is fixed.""" |
425 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 487 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
426 # Tested in testSync. | 488 # Tested in testSync. |
427 self.gclient(['sync', '--deps', 'mac']) | 489 self.gclient(['sync', '--deps', 'mac']) |
428 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') | 490 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') |
429 | 491 |
430 results = self.gclient(['status']) | 492 results = self.gclient(['status']) |
431 out = results[0].splitlines(False) | 493 out = results[0].splitlines(False) |
432 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 494 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 if __name__ == '__main__': | 635 if __name__ == '__main__': |
574 if '-c' in sys.argv: | 636 if '-c' in sys.argv: |
575 COVERAGE = True | 637 COVERAGE = True |
576 sys.argv.remove('-c') | 638 sys.argv.remove('-c') |
577 if os.path.exists('.coverage'): | 639 if os.path.exists('.coverage'): |
578 os.remove('.coverage') | 640 os.remove('.coverage') |
579 os.environ['COVERAGE_FILE'] = os.path.join( | 641 os.environ['COVERAGE_FILE'] = os.path.join( |
580 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 642 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
581 '.coverage') | 643 '.coverage') |
582 unittest.main() | 644 unittest.main() |
OLD | NEW |