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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 self.check(('', '', 0), self.gclient(['diff'])) | 207 self.check(('', '', 0), self.gclient(['diff'])) |
208 self.check(('', '', 0), self.gclient(['export', 'foo'])) | 208 self.check(('', '', 0), self.gclient(['export', 'foo'])) |
209 self.assertTree({}) | 209 self.assertTree({}) |
210 self.check(('', '', 0), self.gclient(['pack'])) | 210 self.check(('', '', 0), self.gclient(['pack'])) |
211 self.check(('', '', 0), self.gclient(['revert'])) | 211 self.check(('', '', 0), self.gclient(['revert'])) |
212 self.assertTree({}) | 212 self.assertTree({}) |
213 self.check(('', '', 0), self.gclient(['runhooks'])) | 213 self.check(('', '', 0), self.gclient(['runhooks'])) |
214 self.assertTree({}) | 214 self.assertTree({}) |
215 self.check(('', '', 0), self.gclient(['status'])) | 215 self.check(('', '', 0), self.gclient(['status'])) |
216 | 216 |
| 217 def testDifferentTopLevelDirectory(self): |
| 218 # Check that even if the .gclient file does not mention the directory src |
| 219 # itself, but it is included via dependencies, the .gclient file is used. |
| 220 self.gclient(['config', self.svn_base + 'trunk/src.DEPS']) |
| 221 deps = join(self.root_dir, 'src.DEPS') |
| 222 os.mkdir(deps) |
| 223 write(join(deps, 'DEPS'), |
| 224 'deps = { "src": "%strunk/src" }' % (self.svn_base)) |
| 225 src = join(self.root_dir, 'src') |
| 226 os.mkdir(src) |
| 227 res = self.gclient(['status'], src) |
| 228 self.checkBlock(res[0], [('running', deps), ('running', src)]) |
| 229 |
217 | 230 |
218 class GClientSmokeSVN(GClientSmokeBase): | 231 class GClientSmokeSVN(GClientSmokeBase): |
219 def setUp(self): | 232 def setUp(self): |
220 GClientSmokeBase.setUp(self) | 233 GClientSmokeBase.setUp(self) |
221 self.FAKE_REPOS.setUpSVN() | 234 self.FAKE_REPOS.setUpSVN() |
222 | 235 |
223 def testSync(self): | 236 def testSync(self): |
224 # TODO(maruel): safesync. | 237 # TODO(maruel): safesync. |
225 self.gclient(['config', self.svn_base + 'trunk/src/']) | 238 self.gclient(['config', self.svn_base + 'trunk/src/']) |
226 # Test unversioned checkout. | 239 # Test unversioned checkout. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 ' "src/other": \'%(base)s/other@2\',\n' | 467 ' "src/other": \'%(base)s/other@2\',\n' |
455 ' "src/third_party/foo": ' | 468 ' "src/third_party/foo": ' |
456 '\'%(base)s/third_party/foo@1\',\n' | 469 '\'%(base)s/third_party/foo@1\',\n' |
457 ' },\n' | 470 ' },\n' |
458 ' "safesync_url": "",\n' | 471 ' "safesync_url": "",\n' |
459 ' },\n' | 472 ' },\n' |
460 ']\n\n' % | 473 ']\n\n' % |
461 { 'base': self.svn_base + 'trunk' }) | 474 { 'base': self.svn_base + 'trunk' }) |
462 self.check((out, '', 0), results) | 475 self.check((out, '', 0), results) |
463 | 476 |
| 477 def testWrongDirectory(self): |
| 478 # Check that we're not using a .gclient configuration which only talks |
| 479 # about a subdirectory src when we're in a different subdirectory src-other. |
| 480 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 481 self.gclient(['sync']) |
| 482 other_src = join(self.root_dir, 'src-other') |
| 483 os.mkdir(other_src) |
| 484 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) |
| 485 self.check(res, self.gclient(['status'], other_src)) |
| 486 |
| 487 def testCorrectDirectory(self): |
| 488 # Check that when we're in the subdirectory src, the .gclient configuration |
| 489 # is used. |
| 490 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 491 self.gclient(['sync']) |
| 492 src = join(self.root_dir, 'src') |
| 493 res = self.gclient(['status'], src) |
| 494 self.checkBlock(res[0], [('running', src)]) |
| 495 |
| 496 def testInitialCheckoutNotYetDone(self): |
| 497 # Check that gclient can be executed when the initial checkout hasn't been |
| 498 # done yet. |
| 499 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 500 self.parseGclient(['sync'], |
| 501 ['running', 'running', |
| 502 # This is due to the way svn update is called for a |
| 503 # single file when File() is used in a DEPS file. |
| 504 ('running', self.root_dir + '/src/file/other'), |
| 505 'running', 'running', 'running', 'running']) |
| 506 |
| 507 def testInitialCheckoutFailed(self): |
| 508 # Check that gclient can be executed from an arbitrary sub directory if the |
| 509 # initial checkout has failed. |
| 510 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 511 self.gclient(['sync']) |
| 512 # Cripple the checkout. |
| 513 os.remove(join(self.root_dir, '.gclient_entries')) |
| 514 src = join(self.root_dir, 'src') |
| 515 res = self.gclient(['sync'], src) |
| 516 self.checkBlock(res[0], |
| 517 ['running', 'running', 'running']) |
| 518 |
464 | 519 |
465 class GClientSmokeGIT(GClientSmokeBase): | 520 class GClientSmokeGIT(GClientSmokeBase): |
466 def setUp(self): | 521 def setUp(self): |
467 GClientSmokeBase.setUp(self) | 522 GClientSmokeBase.setUp(self) |
468 self.enabled = self.FAKE_REPOS.setUpGIT() | 523 self.enabled = self.FAKE_REPOS.setUpGIT() |
469 | 524 |
470 def testSync(self): | 525 def testSync(self): |
471 if not self.enabled: | 526 if not self.enabled: |
472 return | 527 return |
473 # TODO(maruel): safesync. | 528 # TODO(maruel): safesync. |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 if __name__ == '__main__': | 934 if __name__ == '__main__': |
880 if '-c' in sys.argv: | 935 if '-c' in sys.argv: |
881 COVERAGE = True | 936 COVERAGE = True |
882 sys.argv.remove('-c') | 937 sys.argv.remove('-c') |
883 if os.path.exists('.coverage'): | 938 if os.path.exists('.coverage'): |
884 os.remove('.coverage') | 939 os.remove('.coverage') |
885 os.environ['COVERAGE_FILE'] = os.path.join( | 940 os.environ['COVERAGE_FILE'] = os.path.join( |
886 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 941 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
887 '.coverage') | 942 '.coverage') |
888 unittest.main() | 943 unittest.main() |
OLD | NEW |