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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 551 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
552 ('repo_2@1', 'src/repo2'), | 552 ('repo_2@1', 'src/repo2'), |
553 ('repo_3@2', 'src/repo2/repo_renamed')) | 553 ('repo_3@2', 'src/repo2/repo_renamed')) |
554 tree['src/git_hooked1'] = 'git_hooked1' | 554 tree['src/git_hooked1'] = 'git_hooked1' |
555 tree['src/git_hooked2'] = 'git_hooked2' | 555 tree['src/git_hooked2'] = 'git_hooked2' |
556 self.assertTree(tree) | 556 self.assertTree(tree) |
557 | 557 |
558 def testRevInfo(self): | 558 def testRevInfo(self): |
559 if not self.enabled: | 559 if not self.enabled: |
560 return | 560 return |
| 561 # TODO(maruel): Test multiple solutions. |
561 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 562 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
562 self.gclient(['sync', '--deps', 'mac']) | 563 self.gclient(['sync', '--deps', 'mac']) |
563 results = self.gclient(['revinfo', '--deps', 'mac']) | 564 results = self.gclient(['revinfo', '--deps', 'mac']) |
564 out = ('src: %(base)srepo_1@%(hash1)s;\n' | 565 out = ('src: %(base)srepo_1@%(hash1)s;\n' |
565 'src/repo2: %(base)srepo_2@%(hash2)s;\n' | 566 'src/repo2: %(base)srepo_2@%(hash2)s;\n' |
566 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % | 567 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % |
567 { | 568 { |
568 'base': self.git_base, | 569 'base': self.git_base, |
569 'hash1': self.githash('repo_1', 2), | 570 'hash1': self.githash('repo_1', 2), |
570 'hash2': self.githash('repo_2', 1), | 571 'hash2': self.githash('repo_2', 1), |
(...skipping 14 matching lines...) Expand all Loading... |
585 self.gclient(['config', '--spec', | 586 self.gclient(['config', '--spec', |
586 'solutions=[' | 587 'solutions=[' |
587 '{"name": "src",' | 588 '{"name": "src",' |
588 ' "url": "' + self.svn_base + 'trunk/src/"},' | 589 ' "url": "' + self.svn_base + 'trunk/src/"},' |
589 '{"name": "src-git",' | 590 '{"name": "src-git",' |
590 '"url": "' + self.git_base + 'repo_1"}]']) | 591 '"url": "' + self.git_base + 'repo_1"}]']) |
591 results = self.gclient(['sync', '--deps', 'mac']) | 592 results = self.gclient(['sync', '--deps', 'mac']) |
592 # 3x svn checkout, 3x run hooks | 593 # 3x svn checkout, 3x run hooks |
593 self.checkBlock(results[0], | 594 self.checkBlock(results[0], |
594 ['running', 'running', 'running', 'running', 'running', | 595 ['running', 'running', 'running', 'running', 'running', |
595 'running']) | 596 'running', 'running']) |
596 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to | 597 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
597 # new branch \'hash\''. | 598 # new branch \'hash\''. |
598 #self.checkString('', results[1]) | 599 #self.checkString('', results[1]) |
599 self.assertEquals(0, results[2]) | 600 self.assertEquals(0, results[2]) |
600 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), | 601 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), |
601 ('repo_2@1', 'src/repo2'), | 602 ('repo_2@1', 'src/repo2'), |
602 ('repo_3@2', 'src/repo2/repo_renamed')) | 603 ('repo_3@2', 'src/repo2/repo_renamed')) |
603 tree.update(self.mangle_svn_tree( | 604 tree.update(self.mangle_svn_tree( |
604 ('trunk/src@2', 'src'), | 605 ('trunk/src@2', 'src'), |
605 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 606 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
606 ('trunk/other@2', 'src/other'))) | 607 ('trunk/other@2', 'src/other'))) |
607 tree['src/git_hooked1'] = 'git_hooked1' | 608 tree['src/git_hooked1'] = 'git_hooked1' |
608 tree['src/git_hooked2'] = 'git_hooked2' | 609 tree['src/git_hooked2'] = 'git_hooked2' |
609 tree['src/svn_hooked1'] = 'svn_hooked1' | 610 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 611 tree['src/svn_hooked2'] = 'svn_hooked2' |
610 self.assertTree(tree) | 612 self.assertTree(tree) |
611 | 613 |
612 def testMultiSolutionsMultiRev(self): | 614 def testMultiSolutionsMultiRev(self): |
613 if not self.enabled: | 615 if not self.enabled: |
614 return | 616 return |
615 self.gclient(['config', '--spec', | 617 self.gclient(['config', '--spec', |
616 'solutions=[' | 618 'solutions=[' |
617 '{"name": "src",' | 619 '{"name": "src",' |
618 ' "url": "' + self.svn_base + 'trunk/src/"},' | 620 ' "url": "' + self.svn_base + 'trunk/src/"},' |
619 '{"name": "src-git",' | 621 '{"name": "src-git",' |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 return | 668 return |
667 self.gclient(['config', '--spec', | 669 self.gclient(['config', '--spec', |
668 'solutions=[' | 670 'solutions=[' |
669 '{"name": "src",' | 671 '{"name": "src",' |
670 ' "url": "' + self.svn_base + 'trunk/src/"},' | 672 ' "url": "' + self.svn_base + 'trunk/src/"},' |
671 '{"name": "src-git",' | 673 '{"name": "src-git",' |
672 '"url": "' + self.git_base + 'repo_1"}]']) | 674 '"url": "' + self.git_base + 'repo_1"}]']) |
673 self.gclient(['sync', '--deps', 'mac']) | 675 self.gclient(['sync', '--deps', 'mac']) |
674 results = self.gclient(['recurse', 'sh', '-c', | 676 results = self.gclient(['recurse', 'sh', '-c', |
675 'echo $GCLIENT_SCM,$GCLIENT_URL,`pwd`']) | 677 'echo $GCLIENT_SCM,$GCLIENT_URL,`pwd`']) |
676 | 678 |
677 entries = [tuple(line.split(',')) | 679 entries = [tuple(line.split(',')) |
678 for line in results[0].strip().split('\n')] | 680 for line in results[0].strip().split('\n')] |
679 logging.debug(entries) | 681 logging.debug(entries) |
680 | 682 |
681 bases = {'svn': self.svn_base, 'git': self.git_base} | 683 bases = {'svn': self.svn_base, 'git': self.git_base} |
682 expected_source = [ | 684 expected_source = [ |
683 ('svn', 'trunk/src/', 'src'), | 685 ('svn', 'trunk/src/', 'src'), |
684 ('git', 'repo_1', 'src-git'), | 686 ('git', 'repo_1', 'src-git'), |
685 ('svn', 'trunk/other', 'src/other'), | 687 ('svn', 'trunk/other', 'src/other'), |
686 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), | 688 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), |
687 ('git', 'repo_3', 'src/repo2/repo_renamed'), | 689 ('git', 'repo_3', 'src/repo2/repo_renamed'), |
688 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), | 690 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), |
689 ] | 691 ] |
690 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) | 692 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) |
691 for (scm, url, path) in expected_source] | 693 for (scm, url, path) in expected_source] |
692 | 694 |
693 self.assertEquals(sorted(entries), sorted(expected)) | 695 self.assertEquals(sorted(entries), sorted(expected)) |
694 | 696 |
695 | 697 |
696 if __name__ == '__main__': | 698 if __name__ == '__main__': |
697 if '-c' in sys.argv: | 699 if '-c' in sys.argv: |
698 COVERAGE = True | 700 COVERAGE = True |
699 sys.argv.remove('-c') | 701 sys.argv.remove('-c') |
700 if os.path.exists('.coverage'): | 702 if os.path.exists('.coverage'): |
701 os.remove('.coverage') | 703 os.remove('.coverage') |
702 os.environ['COVERAGE_FILE'] = os.path.join( | 704 os.environ['COVERAGE_FILE'] = os.path.join( |
703 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 705 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
704 '.coverage') | 706 '.coverage') |
705 unittest.main() | 707 unittest.main() |
OLD | NEW |