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