| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 self.checkString('hi', out[1][1]) | 537 self.checkString('hi', out[1][1]) |
| 538 self.assertEquals(5, len(out[0])) | 538 self.assertEquals(5, len(out[0])) |
| 539 self.assertEquals(2, len(out[1])) | 539 self.assertEquals(2, len(out[1])) |
| 540 | 540 |
| 541 # Revert implies --force implies running hooks without looking at pattern | 541 # Revert implies --force implies running hooks without looking at pattern |
| 542 # matching. | 542 # matching. |
| 543 results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1']) | 543 results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1']) |
| 544 out = self.splitBlock(results[0]) | 544 out = self.splitBlock(results[0]) |
| 545 # src, src/other is missing, src/other, src/third_party/foo is missing, | 545 # src, src/other is missing, src/other, src/third_party/foo is missing, |
| 546 # src/third_party/foo, 2 svn hooks, 3 related to File(). | 546 # src/third_party/foo, 2 svn hooks, 3 related to File(). |
| 547 self.assertEquals(10, len(out)) | 547 self.assertEquals( 8, len(out)) |
| 548 self.checkString('', results[1]) | 548 self.checkString('', results[1]) |
| 549 self.assertEquals(0, results[2]) | 549 self.assertEquals(0, results[2]) |
| 550 tree = self.mangle_svn_tree( | 550 tree = self.mangle_svn_tree( |
| 551 ('trunk/src@2', 'src'), | 551 ('trunk/src@2', 'src'), |
| 552 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 552 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
| 553 ('trunk/other@2', 'src/other')) | 553 ('trunk/other@2', 'src/other')) |
| 554 tree['src/file/other/DEPS'] = ( | 554 tree['src/file/other/DEPS'] = ( |
| 555 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) | 555 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) |
| 556 tree['src/svn_hooked1'] = 'svn_hooked1' | 556 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 557 tree['src/svn_hooked2'] = 'svn_hooked2' | 557 tree['src/svn_hooked2'] = 'svn_hooked2' |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 self.assertEquals(2, len(out[1])) | 590 self.assertEquals(2, len(out[1])) |
| 591 | 591 |
| 592 # So verify it works with --verbose. | 592 # So verify it works with --verbose. |
| 593 out = self.parseGclient( | 593 out = self.parseGclient( |
| 594 ['status', '--deps', 'mac', '--verbose', '--jobs', '1'], | 594 ['status', '--deps', 'mac', '--verbose', '--jobs', '1'], |
| 595 [['running', join(self.root_dir, 'src')], | 595 [['running', join(self.root_dir, 'src')], |
| 596 ['running', join(self.root_dir, 'src', 'other')], | 596 ['running', join(self.root_dir, 'src', 'other')], |
| 597 ['running', join(self.root_dir, 'src', 'third_party', 'fpp')], | 597 ['running', join(self.root_dir, 'src', 'third_party', 'fpp')], |
| 598 ['running', join(self.root_dir, 'src', 'third_party', 'prout')]]) | 598 ['running', join(self.root_dir, 'src', 'third_party', 'prout')]]) |
| 599 out = self.svnBlockCleanup(out) | 599 out = self.svnBlockCleanup(out) |
| 600 self.checkString('other', out[0][1]) | 600 self.checkString('other', out[0][5]) |
| 601 self.checkString(join('third_party', 'fpp'), out[0][2]) | 601 self.checkString(join('third_party', 'fpp'), out[0][7]) |
| 602 self.checkString(join('third_party', 'prout'), out[0][3]) | 602 self.checkString(join('third_party', 'prout'), out[0][8]) |
| 603 self.checkString('hi', out[1][1]) | 603 self.checkString('hi', out[1][5]) |
| 604 self.assertEquals(4, len(out[0])) | 604 self.assertEquals(9, len(out[0])) |
| 605 self.assertEquals(2, len(out[1])) | 605 self.assertEquals(7, len(out[1])) |
| 606 self.assertEquals(1, len(out[2])) | 606 self.assertEquals(6, len(out[2])) |
| 607 self.assertEquals(1, len(out[3])) | 607 self.assertEquals(6, len(out[3])) |
| 608 self.assertEquals(4, len(out)) | 608 self.assertEquals(4, len(out)) |
| 609 | 609 |
| 610 # Revert implies --force implies running hooks without looking at pattern | 610 # Revert implies --force implies running hooks without looking at pattern |
| 611 # matching. | 611 # matching. |
| 612 # TODO(maruel): In general, gclient revert output is wrong. It should output | 612 # TODO(maruel): In general, gclient revert output is wrong. It should output |
| 613 # the file list after some ___ running 'svn status' | 613 # the file list after some ___ running 'svn status' |
| 614 results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1']) | 614 results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1']) |
| 615 out = self.splitBlock(results[0]) | 615 out = self.splitBlock(results[0]) |
| 616 self.assertEquals(7, len(out)) | 616 self.assertEquals(4, len(out)) |
| 617 self.checkString('', results[1]) | 617 self.checkString('', results[1]) |
| 618 self.assertEquals(0, results[2]) | 618 self.assertEquals(0, results[2]) |
| 619 tree = self.mangle_svn_tree( | 619 tree = self.mangle_svn_tree( |
| 620 ('trunk/src@1', 'src'), | 620 ('trunk/src@1', 'src'), |
| 621 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 621 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
| 622 ('trunk/other@1', 'src/other'), | 622 ('trunk/other@1', 'src/other'), |
| 623 ('trunk/third_party/prout@2', 'src/third_party/prout')) | 623 ('trunk/third_party/prout@2', 'src/third_party/prout')) |
| 624 self.assertTree(tree) | 624 self.assertTree(tree) |
| 625 | 625 |
| 626 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], | 626 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 self.enabled = self.FAKE_REPOS.set_up_git() | 841 self.enabled = self.FAKE_REPOS.set_up_git() |
| 842 | 842 |
| 843 def testSync(self): | 843 def testSync(self): |
| 844 if not self.enabled: | 844 if not self.enabled: |
| 845 return | 845 return |
| 846 # TODO(maruel): safesync. | 846 # TODO(maruel): safesync. |
| 847 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 847 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 848 # Test unversioned checkout. | 848 # Test unversioned checkout. |
| 849 self.parseGclient( | 849 self.parseGclient( |
| 850 ['sync', '--deps', 'mac', '--jobs', '1'], | 850 ['sync', '--deps', 'mac', '--jobs', '1'], |
| 851 ['running', 'running', 'running', 'running', 'running']) | 851 ['running', 'running']) |
| 852 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must | 852 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must |
| 853 # add sync parsing to get the list of updated files. | 853 # add sync parsing to get the list of updated files. |
| 854 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 854 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 855 ('repo_2@1', 'src/repo2'), | 855 ('repo_2@1', 'src/repo2'), |
| 856 ('repo_3@2', 'src/repo2/repo_renamed')) | 856 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 857 tree['src/git_hooked1'] = 'git_hooked1' | 857 tree['src/git_hooked1'] = 'git_hooked1' |
| 858 tree['src/git_hooked2'] = 'git_hooked2' | 858 tree['src/git_hooked2'] = 'git_hooked2' |
| 859 self.assertTree(tree) | 859 self.assertTree(tree) |
| 860 | 860 |
| 861 # Manually remove git_hooked1 before synching to make sure it's not | 861 # Manually remove git_hooked1 before synching to make sure it's not |
| 862 # recreated. | 862 # recreated. |
| 863 os.remove(join(self.root_dir, 'src', 'git_hooked1')) | 863 os.remove(join(self.root_dir, 'src', 'git_hooked1')) |
| 864 | 864 |
| 865 # Test incremental versioned sync: sync backward. | 865 # Test incremental versioned sync: sync backward. |
| 866 self.parseGclient( | 866 self.parseGclient( |
| 867 ['sync', '--jobs', '1', '--revision', | 867 ['sync', '--jobs', '1', '--revision', |
| 868 'src@' + self.githash('repo_1', 1), | 868 'src@' + self.githash('repo_1', 1), |
| 869 '--deps', 'mac', '--delete_unversioned_trees'], | 869 '--deps', 'mac', '--delete_unversioned_trees'], |
| 870 ['running', 'running', 'deleting']) | 870 ['deleting']) |
| 871 tree = self.mangle_git_tree(('repo_1@1', 'src'), | 871 tree = self.mangle_git_tree(('repo_1@1', 'src'), |
| 872 ('repo_2@2', 'src/repo2'), | 872 ('repo_2@2', 'src/repo2'), |
| 873 ('repo_3@1', 'src/repo2/repo3'), | 873 ('repo_3@1', 'src/repo2/repo3'), |
| 874 ('repo_4@2', 'src/repo4')) | 874 ('repo_4@2', 'src/repo4')) |
| 875 tree['src/git_hooked2'] = 'git_hooked2' | 875 tree['src/git_hooked2'] = 'git_hooked2' |
| 876 self.assertTree(tree) | 876 self.assertTree(tree) |
| 877 # Test incremental sync: delete-unversioned_trees isn't there. | 877 # Test incremental sync: delete-unversioned_trees isn't there. |
| 878 self.parseGclient( | 878 self.parseGclient( |
| 879 ['sync', '--deps', 'mac', '--jobs', '1'], | 879 ['sync', '--deps', 'mac', '--jobs', '1'], |
| 880 ['running', 'running', 'running']) | 880 ['running', 'running']) |
| 881 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 881 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 882 ('repo_2@1', 'src/repo2'), | 882 ('repo_2@1', 'src/repo2'), |
| 883 ('repo_3@1', 'src/repo2/repo3'), | 883 ('repo_3@1', 'src/repo2/repo3'), |
| 884 ('repo_3@2', 'src/repo2/repo_renamed'), | 884 ('repo_3@2', 'src/repo2/repo_renamed'), |
| 885 ('repo_4@2', 'src/repo4')) | 885 ('repo_4@2', 'src/repo4')) |
| 886 tree['src/git_hooked1'] = 'git_hooked1' | 886 tree['src/git_hooked1'] = 'git_hooked1' |
| 887 tree['src/git_hooked2'] = 'git_hooked2' | 887 tree['src/git_hooked2'] = 'git_hooked2' |
| 888 self.assertTree(tree) | 888 self.assertTree(tree) |
| 889 | 889 |
| 890 def testSyncIgnoredSolutionName(self): | 890 def testSyncIgnoredSolutionName(self): |
| 891 """TODO(maruel): This will become an error soon.""" | 891 """TODO(maruel): This will become an error soon.""" |
| 892 if not self.enabled: | 892 if not self.enabled: |
| 893 return | 893 return |
| 894 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 894 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 895 self.parseGclient( | 895 self.parseGclient( |
| 896 ['sync', '--deps', 'mac', '--jobs', '1', | 896 ['sync', '--deps', 'mac', '--jobs', '1', |
| 897 '--revision', 'invalid@' + self.githash('repo_1', 1)], | 897 '--revision', 'invalid@' + self.githash('repo_1', 1)], |
| 898 ['running', 'running', 'running', 'running', 'running'], | 898 ['running', 'running'], |
| 899 'Please fix your script, having invalid --revision flags ' | 899 'Please fix your script, having invalid --revision flags ' |
| 900 'will soon considered an error.\n') | 900 'will soon considered an error.\n') |
| 901 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 901 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 902 ('repo_2@1', 'src/repo2'), | 902 ('repo_2@1', 'src/repo2'), |
| 903 ('repo_3@2', 'src/repo2/repo_renamed')) | 903 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 904 tree['src/git_hooked1'] = 'git_hooked1' | 904 tree['src/git_hooked1'] = 'git_hooked1' |
| 905 tree['src/git_hooked2'] = 'git_hooked2' | 905 tree['src/git_hooked2'] = 'git_hooked2' |
| 906 self.assertTree(tree) | 906 self.assertTree(tree) |
| 907 | 907 |
| 908 def testSyncNoSolutionName(self): | 908 def testSyncNoSolutionName(self): |
| 909 if not self.enabled: | 909 if not self.enabled: |
| 910 return | 910 return |
| 911 # When no solution name is provided, gclient uses the first solution listed. | 911 # When no solution name is provided, gclient uses the first solution listed. |
| 912 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 912 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 913 self.parseGclient( | 913 self.parseGclient( |
| 914 ['sync', '--deps', 'mac', '--jobs', '1', | 914 ['sync', '--deps', 'mac', '--jobs', '1', |
| 915 '--revision', self.githash('repo_1', 1)], | 915 '--revision', self.githash('repo_1', 1)], |
| 916 ['running', 'running', 'running', 'running']) | 916 []) |
| 917 tree = self.mangle_git_tree(('repo_1@1', 'src'), | 917 tree = self.mangle_git_tree(('repo_1@1', 'src'), |
| 918 ('repo_2@2', 'src/repo2'), | 918 ('repo_2@2', 'src/repo2'), |
| 919 ('repo_3@1', 'src/repo2/repo3'), | 919 ('repo_3@1', 'src/repo2/repo3'), |
| 920 ('repo_4@2', 'src/repo4')) | 920 ('repo_4@2', 'src/repo4')) |
| 921 self.assertTree(tree) | 921 self.assertTree(tree) |
| 922 | 922 |
| 923 def testSyncJobs(self): | 923 def testSyncJobs(self): |
| 924 if not self.enabled: | 924 if not self.enabled: |
| 925 return | 925 return |
| 926 # TODO(maruel): safesync. | 926 # TODO(maruel): safesync. |
| 927 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 927 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 928 # Test unversioned checkout. | 928 # Test unversioned checkout. |
| 929 self.parseGclient( | 929 self.parseGclient( |
| 930 ['sync', '--deps', 'mac', '--jobs', '8'], | 930 ['sync', '--deps', 'mac', '--jobs', '8'], |
| 931 ['running', 'running', 'running', 'running', 'running'], | 931 ['running', 'running'], |
| 932 untangle=True) | 932 untangle=True) |
| 933 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must | 933 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must |
| 934 # add sync parsing to get the list of updated files. | 934 # add sync parsing to get the list of updated files. |
| 935 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 935 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 936 ('repo_2@1', 'src/repo2'), | 936 ('repo_2@1', 'src/repo2'), |
| 937 ('repo_3@2', 'src/repo2/repo_renamed')) | 937 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 938 tree['src/git_hooked1'] = 'git_hooked1' | 938 tree['src/git_hooked1'] = 'git_hooked1' |
| 939 tree['src/git_hooked2'] = 'git_hooked2' | 939 tree['src/git_hooked2'] = 'git_hooked2' |
| 940 self.assertTree(tree) | 940 self.assertTree(tree) |
| 941 | 941 |
| 942 # Manually remove git_hooked1 before synching to make sure it's not | 942 # Manually remove git_hooked1 before synching to make sure it's not |
| 943 # recreated. | 943 # recreated. |
| 944 os.remove(join(self.root_dir, 'src', 'git_hooked1')) | 944 os.remove(join(self.root_dir, 'src', 'git_hooked1')) |
| 945 | 945 |
| 946 # Test incremental versioned sync: sync backward. | 946 # Test incremental versioned sync: sync backward. |
| 947 # Use --jobs 1 otherwise the order is not deterministic. | 947 # Use --jobs 1 otherwise the order is not deterministic. |
| 948 self.parseGclient( | 948 self.parseGclient( |
| 949 ['sync', '--revision', 'src@' + self.githash('repo_1', 1), | 949 ['sync', '--revision', 'src@' + self.githash('repo_1', 1), |
| 950 '--deps', 'mac', '--delete_unversioned_trees', '--jobs', '1'], | 950 '--deps', 'mac', '--delete_unversioned_trees', '--jobs', '1'], |
| 951 [ 'running', 'running', 'deleting'], | 951 ['deleting'], |
| 952 untangle=True) | 952 untangle=True) |
| 953 tree = self.mangle_git_tree(('repo_1@1', 'src'), | 953 tree = self.mangle_git_tree(('repo_1@1', 'src'), |
| 954 ('repo_2@2', 'src/repo2'), | 954 ('repo_2@2', 'src/repo2'), |
| 955 ('repo_3@1', 'src/repo2/repo3'), | 955 ('repo_3@1', 'src/repo2/repo3'), |
| 956 ('repo_4@2', 'src/repo4')) | 956 ('repo_4@2', 'src/repo4')) |
| 957 tree['src/git_hooked2'] = 'git_hooked2' | 957 tree['src/git_hooked2'] = 'git_hooked2' |
| 958 self.assertTree(tree) | 958 self.assertTree(tree) |
| 959 # Test incremental sync: delete-unversioned_trees isn't there. | 959 # Test incremental sync: delete-unversioned_trees isn't there. |
| 960 self.parseGclient( | 960 self.parseGclient( |
| 961 ['sync', '--deps', 'mac', '--jobs', '8'], | 961 ['sync', '--deps', 'mac', '--jobs', '8'], |
| 962 ['running', 'running', 'running'], | 962 ['running', 'running'], |
| 963 untangle=True) | 963 untangle=True) |
| 964 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 964 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 965 ('repo_2@1', 'src/repo2'), | 965 ('repo_2@1', 'src/repo2'), |
| 966 ('repo_3@1', 'src/repo2/repo3'), | 966 ('repo_3@1', 'src/repo2/repo3'), |
| 967 ('repo_3@2', 'src/repo2/repo_renamed'), | 967 ('repo_3@2', 'src/repo2/repo_renamed'), |
| 968 ('repo_4@2', 'src/repo4')) | 968 ('repo_4@2', 'src/repo4')) |
| 969 tree['src/git_hooked1'] = 'git_hooked1' | 969 tree['src/git_hooked1'] = 'git_hooked1' |
| 970 tree['src/git_hooked2'] = 'git_hooked2' | 970 tree['src/git_hooked2'] = 'git_hooked2' |
| 971 self.assertTree(tree) | 971 self.assertTree(tree) |
| 972 | 972 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 994 ('repo_3@2', 'src/repo2/repo_renamed')) | 994 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 995 tree['src/git_hooked1'] = 'git_hooked1' | 995 tree['src/git_hooked1'] = 'git_hooked1' |
| 996 tree['src/git_hooked2'] = 'git_hooked2' | 996 tree['src/git_hooked2'] = 'git_hooked2' |
| 997 self.assertTree(tree) | 997 self.assertTree(tree) |
| 998 | 998 |
| 999 def testPreDepsHooks(self): | 999 def testPreDepsHooks(self): |
| 1000 if not self.enabled: | 1000 if not self.enabled: |
| 1001 return | 1001 return |
| 1002 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) | 1002 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) |
| 1003 expectation = [ | 1003 expectation = [ |
| 1004 ('running', self.root_dir), # git clone repo_5 | |
| 1005 ('running', self.root_dir), # pre-deps hook | 1004 ('running', self.root_dir), # pre-deps hook |
| 1006 ('running', self.root_dir), # git clone repo_1 | |
| 1007 ('running', self.root_dir), # git clone repo_1 | |
| 1008 ] | 1005 ] |
| 1009 out = self.parseGclient(['sync', '--deps', 'mac', '--jobs=1', | 1006 out = self.parseGclient(['sync', '--deps', 'mac', '--jobs=1', |
| 1010 '--revision', 'src@' + self.githash('repo_5', 2)], | 1007 '--revision', 'src@' + self.githash('repo_5', 2)], |
| 1011 expectation) | 1008 expectation) |
| 1012 self.assertEquals(2, len(out[1])) | 1009 self.assertEquals(2, len(out[0])) |
| 1013 self.assertEquals('pre-deps hook', out[1][1]) | 1010 self.assertEquals('pre-deps hook', out[0][1]) |
| 1014 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1011 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
| 1015 ('repo_1@2', 'src/repo1'), | 1012 ('repo_1@2', 'src/repo1'), |
| 1016 ('repo_2@1', 'src/repo2') | 1013 ('repo_2@1', 'src/repo2') |
| 1017 ) | 1014 ) |
| 1018 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' | 1015 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' |
| 1019 self.assertTree(tree) | 1016 self.assertTree(tree) |
| 1020 | 1017 |
| 1021 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) | 1018 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) |
| 1022 | 1019 |
| 1023 # Pre-DEPS hooks don't run with runhooks. | 1020 # Pre-DEPS hooks don't run with runhooks. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1047 ('repo_1@2', 'src/repo1'), | 1044 ('repo_1@2', 'src/repo1'), |
| 1048 ('repo_2@1', 'src/repo2') | 1045 ('repo_2@1', 'src/repo2') |
| 1049 ) | 1046 ) |
| 1050 self.assertTree(tree) | 1047 self.assertTree(tree) |
| 1051 | 1048 |
| 1052 def testPreDepsHooksError(self): | 1049 def testPreDepsHooksError(self): |
| 1053 if not self.enabled: | 1050 if not self.enabled: |
| 1054 return | 1051 return |
| 1055 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) | 1052 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) |
| 1056 expectated_stdout = [ | 1053 expectated_stdout = [ |
| 1057 ('running', self.root_dir), # git clone repo_5 | |
| 1058 ('running', self.root_dir), # pre-deps hook | 1054 ('running', self.root_dir), # pre-deps hook |
| 1059 ('running', self.root_dir), # pre-deps hook (fails) | 1055 ('running', self.root_dir), # pre-deps hook (fails) |
| 1060 ] | 1056 ] |
| 1061 expected_stderr = ('Error: Command /usr/bin/python -c import sys; ' | 1057 expected_stderr = ('Error: Command /usr/bin/python -c import sys; ' |
| 1062 'sys.exit(1) returned non-zero exit status 1 in %s\n' | 1058 'sys.exit(1) returned non-zero exit status 1 in %s\n' |
| 1063 % self.root_dir) | 1059 % self.root_dir) |
| 1064 stdout, stderr, retcode = self.gclient(['sync', '--deps', 'mac', '--jobs=1', | 1060 stdout, stderr, retcode = self.gclient(['sync', '--deps', 'mac', '--jobs=1', |
| 1065 '--revision', | 1061 '--revision', |
| 1066 'src@' + self.githash('repo_5', 3)]) | 1062 'src@' + self.githash('repo_5', 3)]) |
| 1067 self.assertEquals(stderr, expected_stderr) | 1063 self.assertEquals(stderr, expected_stderr) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 | 1123 |
| 1128 self.gclient(['config', '--spec', config_template % { | 1124 self.gclient(['config', '--spec', config_template % { |
| 1129 'git_base': self.git_base, | 1125 'git_base': self.git_base, |
| 1130 'custom_vars': {} | 1126 'custom_vars': {} |
| 1131 }]) | 1127 }]) |
| 1132 | 1128 |
| 1133 # Tested in testSync. | 1129 # Tested in testSync. |
| 1134 self.gclient(['sync', '--deps', 'mac']) | 1130 self.gclient(['sync', '--deps', 'mac']) |
| 1135 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') | 1131 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') |
| 1136 | 1132 |
| 1137 expected1 = ('running', os.path.join(self.root_dir, 'src')) | |
| 1138 expected2 = ('running', os.path.join(expected1[1], 'repo2')) | |
| 1139 expected3 = ('running', os.path.join(expected2[1], 'repo_renamed')) | |
| 1140 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], []) | 1133 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], []) |
| 1141 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 1134 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
| 1142 # files. | 1135 # files. |
| 1143 self.assertEquals(0, len(out)) | 1136 self.assertEquals(0, len(out)) |
| 1144 | 1137 |
| 1145 # Revert implies --force implies running hooks without looking at pattern | 1138 # Revert implies --force implies running hooks without looking at pattern |
| 1146 # matching. For each expected path, 'git reset' and 'git clean' are run, so | 1139 # matching. For each expected path, 'git reset' and 'git clean' are run, so |
| 1147 # there should be two results for each. The last two results should reflect | 1140 # there should be two results for each. The last two results should reflect |
| 1148 # writing git_hooked1 and git_hooked2. There's only one result for the third | 1141 # writing git_hooked1 and git_hooked2. There's only one result for the third |
| 1149 # because it is clean and has no output for 'git clean'. | 1142 # because it is clean and has no output for 'git clean'. |
| 1150 expected4 = ('running', self.root_dir) | |
| 1151 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], | 1143 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], |
| 1152 [expected1, expected1, | 1144 ['running', 'running']) |
| 1153 expected2, expected2, | 1145 self.assertEquals(2, len(out)) |
| 1154 expected3, | |
| 1155 expected4, expected4]) | |
| 1156 self.assertEquals(7, len(out)) | |
| 1157 tree = self.mangle_git_tree(('repo_1@3', 'src'), | 1146 tree = self.mangle_git_tree(('repo_1@3', 'src'), |
| 1158 ('repo_2@1', 'src/repo2'), | 1147 ('repo_2@1', 'src/repo2'), |
| 1159 ('repo_3@2', 'src/repo2/repo_renamed')) | 1148 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 1160 tree['src/git_hooked1'] = 'git_hooked1' | 1149 tree['src/git_hooked1'] = 'git_hooked1' |
| 1161 tree['src/git_hooked2'] = 'git_hooked2' | 1150 tree['src/git_hooked2'] = 'git_hooked2' |
| 1162 self.assertTree(tree) | 1151 self.assertTree(tree) |
| 1163 | 1152 |
| 1164 # Make a new commit object in the origin repo, to force reset to fetch. | 1153 # Make a new commit object in the origin repo, to force reset to fetch. |
| 1165 self.FAKE_REPOS._commit_git('repo_2', { # pylint: disable=W0212 | 1154 self.FAKE_REPOS._commit_git('repo_2', { # pylint: disable=W0212 |
| 1166 'origin': 'git/repo_2@3\n', | 1155 'origin': 'git/repo_2@3\n', |
| 1167 }) | 1156 }) |
| 1168 | 1157 |
| 1169 self.gclient(['config', '--spec', config_template % { | 1158 self.gclient(['config', '--spec', config_template % { |
| 1170 'git_base': self.git_base, | 1159 'git_base': self.git_base, |
| 1171 'custom_vars': {'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0] } | 1160 'custom_vars': {'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0] } |
| 1172 }]) | 1161 }]) |
| 1173 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], | 1162 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], |
| 1174 [expected1, expected1, | 1163 ['running', 'running']) |
| 1175 expected2, expected2, | 1164 self.assertEquals(2, len(out)) |
| 1176 expected3, | |
| 1177 expected4, expected4]) | |
| 1178 self.assertEquals(7, len(out)) | |
| 1179 tree = self.mangle_git_tree(('repo_1@3', 'src'), | 1165 tree = self.mangle_git_tree(('repo_1@3', 'src'), |
| 1180 ('repo_2@3', 'src/repo2'), | 1166 ('repo_2@3', 'src/repo2'), |
| 1181 ('repo_3@2', 'src/repo2/repo_renamed')) | 1167 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 1182 tree['src/git_hooked1'] = 'git_hooked1' | 1168 tree['src/git_hooked1'] = 'git_hooked1' |
| 1183 tree['src/git_hooked2'] = 'git_hooked2' | 1169 tree['src/git_hooked2'] = 'git_hooked2' |
| 1184 self.assertTree(tree) | 1170 self.assertTree(tree) |
| 1185 | 1171 |
| 1186 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1']) | 1172 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1']) |
| 1187 out = results[0].splitlines(False) | 1173 out = results[0].splitlines(False) |
| 1188 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 1174 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
| 1189 # files. | 1175 # files. |
| 1190 self.assertEquals(0, len(out)) | 1176 self.assertEquals(0, len(out)) |
| 1191 | 1177 |
| 1192 class GClientSmokeBoth(GClientSmokeBase): | 1178 class GClientSmokeBoth(GClientSmokeBase): |
| 1193 def setUp(self): | 1179 def setUp(self): |
| 1194 super(GClientSmokeBoth, self).setUp() | 1180 super(GClientSmokeBoth, self).setUp() |
| 1195 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git() | 1181 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git() |
| 1196 | 1182 |
| 1197 def testMultiSolutions(self): | 1183 def testMultiSolutions(self): |
| 1198 if not self.enabled: | 1184 if not self.enabled: |
| 1199 return | 1185 return |
| 1200 self.gclient(['config', '--spec', | 1186 self.gclient(['config', '--spec', |
| 1201 'solutions=[' | 1187 'solutions=[' |
| 1202 '{"name": "src",' | 1188 '{"name": "src",' |
| 1203 ' "url": "' + self.svn_base + 'trunk/src/"},' | 1189 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 1204 '{"name": "src-git",' | 1190 '{"name": "src-git",' |
| 1205 '"url": "' + self.git_base + 'repo_1"}]']) | 1191 '"url": "' + self.git_base + 'repo_1"}]']) |
| 1206 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'], | 1192 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'], |
| 1207 ['running', 'running', 'running', | 1193 ['running', 'running', |
| 1208 # This is due to the way svn update is called for a single | 1194 # This is due to the way svn update is called for a single |
| 1209 # file when File() is used in a DEPS file. | 1195 # file when File() is used in a DEPS file. |
| 1210 ('running', self.root_dir + '/src/file/other'), | 1196 ('running', self.root_dir + '/src/file/other'), |
| 1211 'running', 'running', 'running', 'running', | 1197 'running', 'running', 'running', 'running', |
| 1212 'running', 'running', 'running', 'running']) | 1198 'running', 'running']) |
| 1213 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), | 1199 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), |
| 1214 ('repo_2@1', 'src/repo2'), | 1200 ('repo_2@1', 'src/repo2'), |
| 1215 ('repo_3@2', 'src/repo2/repo_renamed')) | 1201 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 1216 tree.update(self.mangle_svn_tree( | 1202 tree.update(self.mangle_svn_tree( |
| 1217 ('trunk/src@2', 'src'), | 1203 ('trunk/src@2', 'src'), |
| 1218 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 1204 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
| 1219 ('trunk/other@2', 'src/other'))) | 1205 ('trunk/other@2', 'src/other'))) |
| 1220 tree['src/file/other/DEPS'] = ( | 1206 tree['src/file/other/DEPS'] = ( |
| 1221 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) | 1207 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) |
| 1222 tree['src/git_hooked1'] = 'git_hooked1' | 1208 tree['src/git_hooked1'] = 'git_hooked1' |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1233 ' "url": "' + self.svn_base + 'trunk/src/"},' | 1219 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 1234 '{"name": "src-git",' | 1220 '{"name": "src-git",' |
| 1235 '"url": "' + self.git_base + 'repo_1"}]']) | 1221 '"url": "' + self.git_base + 'repo_1"}]']) |
| 1236 # There is no guarantee that the ordering will be consistent. | 1222 # There is no guarantee that the ordering will be consistent. |
| 1237 (stdout, stderr, returncode) = self.gclient( | 1223 (stdout, stderr, returncode) = self.gclient( |
| 1238 ['sync', '--deps', 'mac', '--jobs', '8']) | 1224 ['sync', '--deps', 'mac', '--jobs', '8']) |
| 1239 stdout = self.untangle(stdout) | 1225 stdout = self.untangle(stdout) |
| 1240 self.checkString('', stderr) | 1226 self.checkString('', stderr) |
| 1241 self.assertEquals(0, returncode) | 1227 self.assertEquals(0, returncode) |
| 1242 results = self.splitBlock(stdout) | 1228 results = self.splitBlock(stdout) |
| 1243 self.assertEquals(12, len(results)) | 1229 self.assertEquals(9, len(results)) |
| 1244 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), | 1230 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), |
| 1245 ('repo_2@1', 'src/repo2'), | 1231 ('repo_2@1', 'src/repo2'), |
| 1246 ('repo_3@2', 'src/repo2/repo_renamed')) | 1232 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 1247 tree.update(self.mangle_svn_tree( | 1233 tree.update(self.mangle_svn_tree( |
| 1248 ('trunk/src@2', 'src'), | 1234 ('trunk/src@2', 'src'), |
| 1249 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 1235 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
| 1250 ('trunk/other@2', 'src/other'))) | 1236 ('trunk/other@2', 'src/other'))) |
| 1251 tree['src/file/other/DEPS'] = ( | 1237 tree['src/file/other/DEPS'] = ( |
| 1252 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) | 1238 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) |
| 1253 tree['src/git_hooked1'] = 'git_hooked1' | 1239 tree['src/git_hooked1'] = 'git_hooked1' |
| 1254 tree['src/git_hooked2'] = 'git_hooked2' | 1240 tree['src/git_hooked2'] = 'git_hooked2' |
| 1255 tree['src/svn_hooked1'] = 'svn_hooked1' | 1241 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 1256 self.assertTree(tree) | 1242 self.assertTree(tree) |
| 1257 | 1243 |
| 1258 def testMultiSolutionsMultiRev(self): | 1244 def testMultiSolutionsMultiRev(self): |
| 1259 if not self.enabled: | 1245 if not self.enabled: |
| 1260 return | 1246 return |
| 1261 self.gclient(['config', '--spec', | 1247 self.gclient(['config', '--spec', |
| 1262 'solutions=[' | 1248 'solutions=[' |
| 1263 '{"name": "src",' | 1249 '{"name": "src",' |
| 1264 ' "url": "' + self.svn_base + 'trunk/src/"},' | 1250 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 1265 '{"name": "src-git",' | 1251 '{"name": "src-git",' |
| 1266 '"url": "' + self.git_base + 'repo_1"}]']) | 1252 '"url": "' + self.git_base + 'repo_1"}]']) |
| 1267 self.parseGclient( | 1253 self.parseGclient( |
| 1268 ['sync', '--deps', 'mac', '--jobs', '1', '--revision', '1', | 1254 ['sync', '--deps', 'mac', '--jobs', '1', '--revision', '1', |
| 1269 '-r', 'src-git@' + self.githash('repo_1', 1)], | 1255 '-r', 'src-git@' + self.githash('repo_1', 1)], |
| 1270 ['running', 'running', 'running', 'running', 'running', | 1256 ['running', 'running', 'running', 'running'], |
| 1271 'running', 'running', 'running'], | |
| 1272 expected_stderr= | 1257 expected_stderr= |
| 1273 'You must specify the full solution name like --revision src@1\n' | 1258 'You must specify the full solution name like --revision src@1\n' |
| 1274 'when you have multiple solutions setup in your .gclient file.\n' | 1259 'when you have multiple solutions setup in your .gclient file.\n' |
| 1275 'Other solutions present are: src-git.\n') | 1260 'Other solutions present are: src-git.\n') |
| 1276 tree = self.mangle_git_tree(('repo_1@1', 'src-git'), | 1261 tree = self.mangle_git_tree(('repo_1@1', 'src-git'), |
| 1277 ('repo_2@2', 'src/repo2'), | 1262 ('repo_2@2', 'src/repo2'), |
| 1278 ('repo_3@1', 'src/repo2/repo3'), | 1263 ('repo_3@1', 'src/repo2/repo3'), |
| 1279 ('repo_4@2', 'src/repo4')) | 1264 ('repo_4@2', 'src/repo4')) |
| 1280 tree.update(self.mangle_svn_tree( | 1265 tree.update(self.mangle_svn_tree( |
| 1281 ('trunk/src@1', 'src'), | 1266 ('trunk/src@1', 'src'), |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 | 1440 |
| 1456 if '-c' in sys.argv: | 1441 if '-c' in sys.argv: |
| 1457 COVERAGE = True | 1442 COVERAGE = True |
| 1458 sys.argv.remove('-c') | 1443 sys.argv.remove('-c') |
| 1459 if os.path.exists('.coverage'): | 1444 if os.path.exists('.coverage'): |
| 1460 os.remove('.coverage') | 1445 os.remove('.coverage') |
| 1461 os.environ['COVERAGE_FILE'] = os.path.join( | 1446 os.environ['COVERAGE_FILE'] = os.path.join( |
| 1462 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1447 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 1463 '.coverage') | 1448 '.coverage') |
| 1464 unittest.main() | 1449 unittest.main() |
| OLD | NEW |