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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 self.checkString('svn_hooked1', out[0][2]) | 276 self.checkString('svn_hooked1', out[0][2]) |
277 self.checkString(join('third_party', 'foo'), out[0][3]) | 277 self.checkString(join('third_party', 'foo'), out[0][3]) |
278 self.checkString('hi', out[1][1]) | 278 self.checkString('hi', out[1][1]) |
279 self.assertEquals(4, len(out[0])) | 279 self.assertEquals(4, len(out[0])) |
280 self.assertEquals(2, len(out[1])) | 280 self.assertEquals(2, len(out[1])) |
281 | 281 |
282 # Revert implies --force implies running hooks without looking at pattern | 282 # Revert implies --force implies running hooks without looking at pattern |
283 # matching. | 283 # matching. |
284 results = self.gclient(['revert', '--deps', 'mac']) | 284 results = self.gclient(['revert', '--deps', 'mac']) |
285 out = self.splitBlock(results[0]) | 285 out = self.splitBlock(results[0]) |
286 # src, src/other is missing, src/other, src/third_party/foo is missing, | |
287 # src/third_party/foo, 2 svn hooks. | |
288 self.assertEquals(7, len(out)) | 286 self.assertEquals(7, len(out)) |
289 self.checkString('', results[1]) | 287 self.checkString('', results[1]) |
290 self.assertEquals(0, results[2]) | 288 self.assertEquals(0, results[2]) |
291 tree = self.mangle_svn_tree( | 289 tree = self.mangle_svn_tree( |
292 ('trunk/src@2', 'src'), | 290 ('trunk/src@2', 'src'), |
293 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 291 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
294 ('trunk/other@2', 'src/other')) | 292 ('trunk/other@2', 'src/other')) |
295 tree['src/svn_hooked1'] = 'svn_hooked1' | 293 tree['src/svn_hooked1'] = 'svn_hooked1' |
296 tree['src/svn_hooked2'] = 'svn_hooked2' | 294 tree['src/svn_hooked2'] = 'svn_hooked2' |
297 self.assertTree(tree) | 295 self.assertTree(tree) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 self.checkString(1, len(out[0])) | 368 self.checkString(1, len(out[0])) |
371 self.checkString(1, len(out[1])) | 369 self.checkString(1, len(out[1])) |
372 | 370 |
373 def testRunHooksDepsOs(self): | 371 def testRunHooksDepsOs(self): |
374 self.gclient(['config', self.svn_base + 'trunk/src/']) | 372 self.gclient(['config', self.svn_base + 'trunk/src/']) |
375 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 373 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
376 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) | 374 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) |
377 self.assertEquals([], out) | 375 self.assertEquals([], out) |
378 | 376 |
379 def testRevInfo(self): | 377 def testRevInfo(self): |
| 378 # TODO(maruel): Test multiple solutions. |
380 self.gclient(['config', self.svn_base + 'trunk/src/']) | 379 self.gclient(['config', self.svn_base + 'trunk/src/']) |
381 self.gclient(['sync', '--deps', 'mac']) | 380 self.gclient(['sync', '--deps', 'mac']) |
382 results = self.gclient(['revinfo', '--deps', 'mac']) | 381 results = self.gclient(['revinfo', '--deps', 'mac']) |
383 out = ('src: %(base)s/src@2;\n' | 382 out = ('src: %(base)s/src@2;\n' |
384 'src/other: %(base)s/other@2;\n' | 383 'src/other: %(base)s/other@2;\n' |
385 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 384 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
386 { 'base': self.svn_base + 'trunk' }) | 385 { 'base': self.svn_base + 'trunk' }) |
387 self.check((out, '', 0), results) | 386 self.check((out, '', 0), results) |
388 | 387 |
389 | 388 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 def testMultiSolutions(self): | 579 def testMultiSolutions(self): |
581 if not self.enabled: | 580 if not self.enabled: |
582 return | 581 return |
583 self.gclient(['config', '--spec', | 582 self.gclient(['config', '--spec', |
584 'solutions=[' | 583 'solutions=[' |
585 '{"name": "src",' | 584 '{"name": "src",' |
586 ' "url": "' + self.svn_base + 'trunk/src/"},' | 585 ' "url": "' + self.svn_base + 'trunk/src/"},' |
587 '{"name": "src-git",' | 586 '{"name": "src-git",' |
588 '"url": "' + self.git_base + 'repo_1"}]']) | 587 '"url": "' + self.git_base + 'repo_1"}]']) |
589 results = self.gclient(['sync', '--deps', 'mac']) | 588 results = self.gclient(['sync', '--deps', 'mac']) |
590 # 3x svn checkout, 3x run hooks | |
591 self.checkBlock(results[0], | 589 self.checkBlock(results[0], |
592 ['running', 'running', 'running', 'running', 'running', | 590 ['running', 'running', 'running', 'running', 'running', |
593 'running', 'running']) | 591 'running', 'running']) |
594 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to | 592 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
595 # new branch \'hash\''. | 593 # new branch \'hash\''. |
596 #self.checkString('', results[1]) | 594 #self.checkString('', results[1]) |
597 self.assertEquals(0, results[2]) | 595 self.assertEquals(0, results[2]) |
598 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), | 596 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), |
599 ('repo_2@1', 'src/repo2'), | 597 ('repo_2@1', 'src/repo2'), |
600 ('repo_3@2', 'src/repo2/repo_renamed')) | 598 ('repo_3@2', 'src/repo2/repo_renamed')) |
(...skipping 27 matching lines...) Expand all Loading... |
628 ('repo_2@2', 'src/repo2'), | 626 ('repo_2@2', 'src/repo2'), |
629 ('repo_3@1', 'src/repo2/repo3'), | 627 ('repo_3@1', 'src/repo2/repo3'), |
630 ('repo_4@2', 'src/repo4')) | 628 ('repo_4@2', 'src/repo4')) |
631 tree.update(self.mangle_svn_tree( | 629 tree.update(self.mangle_svn_tree( |
632 ('trunk/src@1', 'src'), | 630 ('trunk/src@1', 'src'), |
633 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 631 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
634 ('trunk/other@1', 'src/other'), | 632 ('trunk/other@1', 'src/other'), |
635 ('trunk/third_party/foo@2', 'src/third_party/prout'))) | 633 ('trunk/third_party/foo@2', 'src/third_party/prout'))) |
636 self.assertTree(tree) | 634 self.assertTree(tree) |
637 | 635 |
638 def testRevInfo(self): | |
639 if not self.enabled: | |
640 return | |
641 self.gclient(['config', '--spec', | |
642 'solutions=[' | |
643 '{"name": "src",' | |
644 ' "url": "' + self.svn_base + 'trunk/src/"},' | |
645 '{"name": "src-git",' | |
646 '"url": "' + self.git_base + 'repo_1"}]']) | |
647 self.gclient(['sync', '--deps', 'mac']) | |
648 results = self.gclient(['revinfo', '--deps', 'mac']) | |
649 out = ('src: %(svn_base)s/src/@2;\n' | |
650 'src-git: %(git_base)srepo_1@%(hash1)s;\n' | |
651 'src/other: %(svn_base)s/other@2;\n' | |
652 'src/repo2: %(git_base)srepo_2@%(hash2)s;\n' | |
653 'src/repo2/repo_renamed: %(git_base)srepo_3@%(hash3)s;\n' | |
654 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { | |
655 'svn_base': self.svn_base + 'trunk', | |
656 'git_base': self.git_base, | |
657 'hash1': self.githash('repo_1', 2), | |
658 'hash2': self.githash('repo_2', 1), | |
659 'hash3': self.githash('repo_3', 2), | |
660 } | |
661 self.check((out, '', 0), results) | |
662 | |
663 | 636 |
664 if __name__ == '__main__': | 637 if __name__ == '__main__': |
665 if '-c' in sys.argv: | 638 if '-c' in sys.argv: |
666 COVERAGE = True | 639 COVERAGE = True |
667 sys.argv.remove('-c') | 640 sys.argv.remove('-c') |
668 if os.path.exists('.coverage'): | 641 if os.path.exists('.coverage'): |
669 os.remove('.coverage') | 642 os.remove('.coverage') |
670 os.environ['COVERAGE_FILE'] = os.path.join( | 643 os.environ['COVERAGE_FILE'] = os.path.join( |
671 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 644 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
672 '.coverage') | 645 '.coverage') |
673 unittest.main() | 646 unittest.main() |
OLD | NEW |