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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 def testRunHooksDepsOs(self): | 422 def testRunHooksDepsOs(self): |
423 self.gclient(['config', self.svn_base + 'trunk/src/']) | 423 self.gclient(['config', self.svn_base + 'trunk/src/']) |
424 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 424 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
425 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) | 425 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) |
426 self.assertEquals([], out) | 426 self.assertEquals([], out) |
427 | 427 |
428 def testRevInfo(self): | 428 def testRevInfo(self): |
429 self.gclient(['config', self.svn_base + 'trunk/src/']) | 429 self.gclient(['config', self.svn_base + 'trunk/src/']) |
430 self.gclient(['sync', '--deps', 'mac']) | 430 self.gclient(['sync', '--deps', 'mac']) |
431 results = self.gclient(['revinfo', '--deps', 'mac']) | 431 results = self.gclient(['revinfo', '--deps', 'mac']) |
432 out = ('src: %(base)s/src;\n' | 432 out = ('src: %(base)s/src\n' |
433 'src/file/other: File("%(base)s/other/DEPS");\n' | 433 'src/file/other: File("%(base)s/other/DEPS")\n' |
434 'src/other: %(base)s/other;\n' | 434 'src/other: %(base)s/other\n' |
435 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 435 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
436 { 'base': self.svn_base + 'trunk' }) | 436 { 'base': self.svn_base + 'trunk' }) |
437 self.check((out, '', 0), results) | 437 self.check((out, '', 0), results) |
438 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) | 438 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) |
439 out = ('src: %(base)s/src@2;\n' | 439 out = ('src: %(base)s/src@2\n' |
440 'src/file/other: %(base)s/other/DEPS@2;\n' | 440 'src/file/other: %(base)s/other/DEPS@2\n' |
441 'src/other: %(base)s/other@2;\n' | 441 'src/other: %(base)s/other@2\n' |
442 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 442 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
443 { 'base': self.svn_base + 'trunk' }) | 443 { 'base': self.svn_base + 'trunk' }) |
444 self.check((out, '', 0), results) | 444 self.check((out, '', 0), results) |
445 results = self.gclient(['revinfo', '--deps', 'mac', '--snapshot']) | 445 results = self.gclient(['revinfo', '--deps', 'mac', '--snapshot']) |
446 out = ('# Snapshot generated with gclient revinfo --snapshot\n' | 446 out = ('# Snapshot generated with gclient revinfo --snapshot\n' |
447 'solutions = [\n' | 447 'solutions = [\n' |
448 ' { "name" : "src",\n' | 448 ' { "name" : "src",\n' |
449 ' "url" : "%(base)s/src",\n' | 449 ' "url" : "%(base)s/src",\n' |
450 ' "custom_deps" : {\n' | 450 ' "custom_deps" : {\n' |
451 ' "foo/bar": None,\n' | 451 ' "foo/bar": None,\n' |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 tree['src/git_hooked1'] = 'git_hooked1' | 626 tree['src/git_hooked1'] = 'git_hooked1' |
627 tree['src/git_hooked2'] = 'git_hooked2' | 627 tree['src/git_hooked2'] = 'git_hooked2' |
628 self.assertTree(tree) | 628 self.assertTree(tree) |
629 | 629 |
630 def testRevInfo(self): | 630 def testRevInfo(self): |
631 if not self.enabled: | 631 if not self.enabled: |
632 return | 632 return |
633 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 633 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
634 self.gclient(['sync', '--deps', 'mac']) | 634 self.gclient(['sync', '--deps', 'mac']) |
635 results = self.gclient(['revinfo', '--deps', 'mac']) | 635 results = self.gclient(['revinfo', '--deps', 'mac']) |
636 out = ('src: %(base)srepo_1;\n' | 636 out = ('src: %(base)srepo_1\n' |
637 'src/repo2: %(base)srepo_2@%(hash2)s;\n' | 637 'src/repo2: %(base)srepo_2@%(hash2)s\n' |
638 'src/repo2/repo_renamed: %(base)srepo_3\n' % | 638 'src/repo2/repo_renamed: %(base)srepo_3\n' % |
639 { | 639 { |
640 'base': self.git_base, | 640 'base': self.git_base, |
641 'hash1': self.githash('repo_1', 2)[:7], | 641 'hash1': self.githash('repo_1', 2)[:7], |
642 'hash2': self.githash('repo_2', 1)[:7], | 642 'hash2': self.githash('repo_2', 1)[:7], |
643 'hash3': self.githash('repo_3', 2)[:7], | 643 'hash3': self.githash('repo_3', 2)[:7], |
644 }) | 644 }) |
645 self.check((out, '', 0), results) | 645 self.check((out, '', 0), results) |
646 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) | 646 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) |
647 out = ('src: %(base)srepo_1@%(hash1)s;\n' | 647 out = ('src: %(base)srepo_1@%(hash1)s\n' |
648 'src/repo2: %(base)srepo_2@%(hash2)s;\n' | 648 'src/repo2: %(base)srepo_2@%(hash2)s\n' |
649 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % | 649 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % |
650 { | 650 { |
651 'base': self.git_base, | 651 'base': self.git_base, |
652 'hash1': self.githash('repo_1', 2), | 652 'hash1': self.githash('repo_1', 2), |
653 'hash2': self.githash('repo_2', 1), | 653 'hash2': self.githash('repo_2', 1), |
654 'hash3': self.githash('repo_3', 2), | 654 'hash3': self.githash('repo_3', 2), |
655 }) | 655 }) |
656 self.check((out, '', 0), results) | 656 self.check((out, '', 0), results) |
657 | 657 |
658 | 658 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 if not self.enabled: | 729 if not self.enabled: |
730 return | 730 return |
731 self.gclient(['config', '--spec', | 731 self.gclient(['config', '--spec', |
732 'solutions=[' | 732 'solutions=[' |
733 '{"name": "src",' | 733 '{"name": "src",' |
734 ' "url": "' + self.svn_base + 'trunk/src/"},' | 734 ' "url": "' + self.svn_base + 'trunk/src/"},' |
735 '{"name": "src-git",' | 735 '{"name": "src-git",' |
736 '"url": "' + self.git_base + 'repo_1"}]']) | 736 '"url": "' + self.git_base + 'repo_1"}]']) |
737 self.gclient(['sync', '--deps', 'mac']) | 737 self.gclient(['sync', '--deps', 'mac']) |
738 results = self.gclient(['revinfo', '--deps', 'mac']) | 738 results = self.gclient(['revinfo', '--deps', 'mac']) |
739 out = ('src: %(svn_base)s/src/;\n' | 739 out = ('src: %(svn_base)s/src/\n' |
740 'src-git: %(git_base)srepo_1;\n' | 740 'src-git: %(git_base)srepo_1\n' |
741 'src/file/other: File("%(svn_base)s/other/DEPS");\n' | 741 'src/file/other: File("%(svn_base)s/other/DEPS")\n' |
742 'src/other: %(svn_base)s/other;\n' | 742 'src/other: %(svn_base)s/other\n' |
743 'src/repo2: %(git_base)srepo_2@%(hash2)s;\n' | 743 'src/repo2: %(git_base)srepo_2@%(hash2)s\n' |
744 'src/repo2/repo_renamed: %(git_base)srepo_3;\n' | 744 'src/repo2/repo_renamed: %(git_base)srepo_3\n' |
745 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { | 745 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { |
746 'svn_base': self.svn_base + 'trunk', | 746 'svn_base': self.svn_base + 'trunk', |
747 'git_base': self.git_base, | 747 'git_base': self.git_base, |
748 'hash1': self.githash('repo_1', 2)[:7], | 748 'hash1': self.githash('repo_1', 2)[:7], |
749 'hash2': self.githash('repo_2', 1)[:7], | 749 'hash2': self.githash('repo_2', 1)[:7], |
750 'hash3': self.githash('repo_3', 2)[:7], | 750 'hash3': self.githash('repo_3', 2)[:7], |
751 } | 751 } |
752 self.check((out, '', 0), results) | 752 self.check((out, '', 0), results) |
753 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) | 753 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) |
754 out = ('src: %(svn_base)s/src/@2;\n' | 754 out = ('src: %(svn_base)s/src/@2\n' |
755 'src-git: %(git_base)srepo_1@%(hash1)s;\n' | 755 'src-git: %(git_base)srepo_1@%(hash1)s\n' |
756 'src/file/other: %(svn_base)s/other/DEPS@2;\n' | 756 'src/file/other: %(svn_base)s/other/DEPS@2\n' |
757 'src/other: %(svn_base)s/other@2;\n' | 757 'src/other: %(svn_base)s/other@2\n' |
758 'src/repo2: %(git_base)srepo_2@%(hash2)s;\n' | 758 'src/repo2: %(git_base)srepo_2@%(hash2)s\n' |
759 'src/repo2/repo_renamed: %(git_base)srepo_3@%(hash3)s;\n' | 759 'src/repo2/repo_renamed: %(git_base)srepo_3@%(hash3)s\n' |
760 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { | 760 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { |
761 'svn_base': self.svn_base + 'trunk', | 761 'svn_base': self.svn_base + 'trunk', |
762 'git_base': self.git_base, | 762 'git_base': self.git_base, |
763 'hash1': self.githash('repo_1', 2), | 763 'hash1': self.githash('repo_1', 2), |
764 'hash2': self.githash('repo_2', 1), | 764 'hash2': self.githash('repo_2', 1), |
765 'hash3': self.githash('repo_3', 2), | 765 'hash3': self.githash('repo_3', 2), |
766 } | 766 } |
767 self.check((out, '', 0), results) | 767 self.check((out, '', 0), results) |
768 | 768 |
769 def testRecurse(self): | 769 def testRecurse(self): |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 self.checkString('foo', out[0][1]) | 850 self.checkString('foo', out[0][1]) |
851 tree = self.mangle_svn_tree( | 851 tree = self.mangle_svn_tree( |
852 ('trunk/webkit@2', ''), | 852 ('trunk/webkit@2', ''), |
853 ('trunk/third_party/foo@1', 'foo/bar')) | 853 ('trunk/third_party/foo@1', 'foo/bar')) |
854 self.assertTree(tree) | 854 self.assertTree(tree) |
855 | 855 |
856 def testRevInfo(self): | 856 def testRevInfo(self): |
857 self.gclient(['sync', '--deps', 'mac']) | 857 self.gclient(['sync', '--deps', 'mac']) |
858 results = self.gclient(['revinfo', '--deps', 'mac']) | 858 results = self.gclient(['revinfo', '--deps', 'mac']) |
859 expected = ( | 859 expected = ( |
860 './: None;\nfoo/bar: svn://127.0.0.1/svn/trunk/third_party/foo@1\n', | 860 './: None\nfoo/bar: svn://127.0.0.1/svn/trunk/third_party/foo@1\n', |
861 '', 0) | 861 '', 0) |
862 self.check(expected, results) | 862 self.check(expected, results) |
863 # TODO(maruel): To be added after the refactor. | 863 # TODO(maruel): To be added after the refactor. |
864 #results = self.gclient(['revinfo', '--snapshot']) | 864 #results = self.gclient(['revinfo', '--snapshot']) |
865 #expected = ( | 865 #expected = ( |
866 # './: None;\nfoo/bar: svn://127.0.0.1/svn/trunk/third_party/foo@1\n', | 866 # './: None\nfoo/bar: svn://127.0.0.1/svn/trunk/third_party/foo@1\n', |
867 # '', 0) | 867 # '', 0) |
868 #self.check(expected, results) | 868 #self.check(expected, results) |
869 | 869 |
870 def testRest(self): | 870 def testRest(self): |
871 self.gclient(['sync']) | 871 self.gclient(['sync']) |
872 # TODO(maruel): This is incorrect, it should run on ./ too. | 872 # TODO(maruel): This is incorrect, it should run on ./ too. |
873 out = self.parseGclient(['cleanup', '--deps', 'mac'], | 873 out = self.parseGclient(['cleanup', '--deps', 'mac'], |
874 [('running', join(self.root_dir, 'foo', 'bar'))]) | 874 [('running', join(self.root_dir, 'foo', 'bar'))]) |
875 out = self.parseGclient(['diff', '--deps', 'mac'], | 875 out = self.parseGclient(['diff', '--deps', 'mac'], |
876 [('running', join(self.root_dir, 'foo', 'bar'))]) | 876 [('running', join(self.root_dir, 'foo', 'bar'))]) |
877 | 877 |
878 | 878 |
879 if __name__ == '__main__': | 879 if __name__ == '__main__': |
880 if '-c' in sys.argv: | 880 if '-c' in sys.argv: |
881 COVERAGE = True | 881 COVERAGE = True |
882 sys.argv.remove('-c') | 882 sys.argv.remove('-c') |
883 if os.path.exists('.coverage'): | 883 if os.path.exists('.coverage'): |
884 os.remove('.coverage') | 884 os.remove('.coverage') |
885 os.environ['COVERAGE_FILE'] = os.path.join( | 885 os.environ['COVERAGE_FILE'] = os.path.join( |
886 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 886 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
887 '.coverage') | 887 '.coverage') |
888 unittest.main() | 888 unittest.main() |
OLD | NEW |