Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: tests/gclient_smoketest.py

Issue 218993009: Use CheckCallAndFilterAndHeader for git commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix test cases. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
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', self.root_dir + '/src'), 851 ['running', 'running', 'running', 'running', 'running'])
852 'running', ('running', self.root_dir + '/src/repo2'),
853 'running', ('running', self.root_dir + '/src/repo2/repo_renamed'),
854 'running', 'running'])
855 # 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
856 # add sync parsing to get the list of updated files. 853 # add sync parsing to get the list of updated files.
857 tree = self.mangle_git_tree(('repo_1@2', 'src'), 854 tree = self.mangle_git_tree(('repo_1@2', 'src'),
858 ('repo_2@1', 'src/repo2'), 855 ('repo_2@1', 'src/repo2'),
859 ('repo_3@2', 'src/repo2/repo_renamed')) 856 ('repo_3@2', 'src/repo2/repo_renamed'))
860 tree['src/git_hooked1'] = 'git_hooked1' 857 tree['src/git_hooked1'] = 'git_hooked1'
861 tree['src/git_hooked2'] = 'git_hooked2' 858 tree['src/git_hooked2'] = 'git_hooked2'
862 self.assertTree(tree) 859 self.assertTree(tree)
863 860
864 # 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
865 # recreated. 862 # recreated.
866 os.remove(join(self.root_dir, 'src', 'git_hooked1')) 863 os.remove(join(self.root_dir, 'src', 'git_hooked1'))
867 864
868 # Test incremental versioned sync: sync backward. 865 # Test incremental versioned sync: sync backward.
869 diffdir = os.path.join(self.root_dir, 'src', 'repo2', 'repo_renamed')
870 self.parseGclient( 866 self.parseGclient(
871 ['sync', '--jobs', '1', '--revision', 867 ['sync', '--jobs', '1', '--revision',
872 'src@' + self.githash('repo_1', 1), 868 'src@' + self.githash('repo_1', 1),
873 '--deps', 'mac', '--delete_unversioned_trees'], 869 '--deps', 'mac', '--delete_unversioned_trees'],
874 ['running', ('running', self.root_dir + '/src/repo2/repo3'), 870 ['running', 'running', 'deleting'])
875 'running', ('running', self.root_dir + '/src/repo4'),
876 ('running', diffdir), 'deleting'])
877 tree = self.mangle_git_tree(('repo_1@1', 'src'), 871 tree = self.mangle_git_tree(('repo_1@1', 'src'),
878 ('repo_2@2', 'src/repo2'), 872 ('repo_2@2', 'src/repo2'),
879 ('repo_3@1', 'src/repo2/repo3'), 873 ('repo_3@1', 'src/repo2/repo3'),
880 ('repo_4@2', 'src/repo4')) 874 ('repo_4@2', 'src/repo4'))
881 tree['src/git_hooked2'] = 'git_hooked2' 875 tree['src/git_hooked2'] = 'git_hooked2'
882 self.assertTree(tree) 876 self.assertTree(tree)
883 # Test incremental sync: delete-unversioned_trees isn't there. 877 # Test incremental sync: delete-unversioned_trees isn't there.
884 expect3 = ('running', os.path.join(self.root_dir, 'src', 'repo2', 'repo3'))
885 expect4 = ('running', os.path.join(self.root_dir, 'src', 'repo4'))
886 self.parseGclient( 878 self.parseGclient(
887 ['sync', '--deps', 'mac', '--jobs', '1'], 879 ['sync', '--deps', 'mac', '--jobs', '1'],
888 ['running', ('running', self.root_dir + '/src/repo2/repo_renamed'), 880 ['running', 'running', 'running'])
889 'running', 'running', expect3, expect4])
890 tree = self.mangle_git_tree(('repo_1@2', 'src'), 881 tree = self.mangle_git_tree(('repo_1@2', 'src'),
891 ('repo_2@1', 'src/repo2'), 882 ('repo_2@1', 'src/repo2'),
892 ('repo_3@1', 'src/repo2/repo3'), 883 ('repo_3@1', 'src/repo2/repo3'),
893 ('repo_3@2', 'src/repo2/repo_renamed'), 884 ('repo_3@2', 'src/repo2/repo_renamed'),
894 ('repo_4@2', 'src/repo4')) 885 ('repo_4@2', 'src/repo4'))
895 tree['src/git_hooked1'] = 'git_hooked1' 886 tree['src/git_hooked1'] = 'git_hooked1'
896 tree['src/git_hooked2'] = 'git_hooked2' 887 tree['src/git_hooked2'] = 'git_hooked2'
897 self.assertTree(tree) 888 self.assertTree(tree)
898 889
899 def testSyncIgnoredSolutionName(self): 890 def testSyncIgnoredSolutionName(self):
900 """TODO(maruel): This will become an error soon.""" 891 """TODO(maruel): This will become an error soon."""
901 if not self.enabled: 892 if not self.enabled:
902 return 893 return
903 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) 894 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
904 self.parseGclient( 895 self.parseGclient(
905 ['sync', '--deps', 'mac', '--jobs', '1', 896 ['sync', '--deps', 'mac', '--jobs', '1',
906 '--revision', 'invalid@' + self.githash('repo_1', 1)], 897 '--revision', 'invalid@' + self.githash('repo_1', 1)],
907 ['running', ('running', self.root_dir + '/src'), 898 ['running', 'running', 'running', 'running', 'running'],
908 'running', ('running', self.root_dir + '/src/repo2'),
909 'running', ('running', self.root_dir + '/src/repo2/repo_renamed'),
910 'running', 'running'],
911 'Please fix your script, having invalid --revision flags ' 899 'Please fix your script, having invalid --revision flags '
912 'will soon considered an error.\n') 900 'will soon considered an error.\n')
913 tree = self.mangle_git_tree(('repo_1@2', 'src'), 901 tree = self.mangle_git_tree(('repo_1@2', 'src'),
914 ('repo_2@1', 'src/repo2'), 902 ('repo_2@1', 'src/repo2'),
915 ('repo_3@2', 'src/repo2/repo_renamed')) 903 ('repo_3@2', 'src/repo2/repo_renamed'))
916 tree['src/git_hooked1'] = 'git_hooked1' 904 tree['src/git_hooked1'] = 'git_hooked1'
917 tree['src/git_hooked2'] = 'git_hooked2' 905 tree['src/git_hooked2'] = 'git_hooked2'
918 self.assertTree(tree) 906 self.assertTree(tree)
919 907
920 def testSyncNoSolutionName(self): 908 def testSyncNoSolutionName(self):
921 if not self.enabled: 909 if not self.enabled:
922 return 910 return
923 # 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.
924 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) 912 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
925 self.parseGclient( 913 self.parseGclient(
926 ['sync', '--deps', 'mac', '--jobs', '1', 914 ['sync', '--deps', 'mac', '--jobs', '1',
927 '--revision', self.githash('repo_1', 1)], 915 '--revision', self.githash('repo_1', 1)],
928 ['running', ('running', self.root_dir + '/src'), 916 ['running', 'running', 'running', 'running'])
929 'running', ('running', self.root_dir + '/src/repo2'),
930 'running', ('running', self.root_dir + '/src/repo2/repo3'),
931 'running', ('running', self.root_dir + '/src/repo4')])
932 tree = self.mangle_git_tree(('repo_1@1', 'src'), 917 tree = self.mangle_git_tree(('repo_1@1', 'src'),
933 ('repo_2@2', 'src/repo2'), 918 ('repo_2@2', 'src/repo2'),
934 ('repo_3@1', 'src/repo2/repo3'), 919 ('repo_3@1', 'src/repo2/repo3'),
935 ('repo_4@2', 'src/repo4')) 920 ('repo_4@2', 'src/repo4'))
936 self.assertTree(tree) 921 self.assertTree(tree)
937 922
938 def testSyncJobs(self): 923 def testSyncJobs(self):
939 if not self.enabled: 924 if not self.enabled:
940 return 925 return
941 # TODO(maruel): safesync. 926 # TODO(maruel): safesync.
942 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) 927 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
943 # Test unversioned checkout. 928 # Test unversioned checkout.
944 self.parseGclient( 929 self.parseGclient(
945 ['sync', '--deps', 'mac', '--jobs', '8'], 930 ['sync', '--deps', 'mac', '--jobs', '8'],
946 ['running', ('running', self.root_dir + '/src'), 931 ['running', 'running', 'running', 'running', 'running'],
947 'running', ('running', self.root_dir + '/src/repo2'),
948 'running', ('running', self.root_dir + '/src/repo2/repo_renamed'),
949 'running', 'running'],
950 untangle=True) 932 untangle=True)
951 # 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
952 # add sync parsing to get the list of updated files. 934 # add sync parsing to get the list of updated files.
953 tree = self.mangle_git_tree(('repo_1@2', 'src'), 935 tree = self.mangle_git_tree(('repo_1@2', 'src'),
954 ('repo_2@1', 'src/repo2'), 936 ('repo_2@1', 'src/repo2'),
955 ('repo_3@2', 'src/repo2/repo_renamed')) 937 ('repo_3@2', 'src/repo2/repo_renamed'))
956 tree['src/git_hooked1'] = 'git_hooked1' 938 tree['src/git_hooked1'] = 'git_hooked1'
957 tree['src/git_hooked2'] = 'git_hooked2' 939 tree['src/git_hooked2'] = 'git_hooked2'
958 self.assertTree(tree) 940 self.assertTree(tree)
959 941
960 # 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
961 # recreated. 943 # recreated.
962 os.remove(join(self.root_dir, 'src', 'git_hooked1')) 944 os.remove(join(self.root_dir, 'src', 'git_hooked1'))
963 945
964 # Test incremental versioned sync: sync backward. 946 # Test incremental versioned sync: sync backward.
965 expect3 = ('running',
966 os.path.join(self.root_dir, 'src', 'repo2', 'repo_renamed'))
967 # Use --jobs 1 otherwise the order is not deterministic. 947 # Use --jobs 1 otherwise the order is not deterministic.
968 self.parseGclient( 948 self.parseGclient(
969 ['sync', '--revision', 'src@' + self.githash('repo_1', 1), 949 ['sync', '--revision', 'src@' + self.githash('repo_1', 1),
970 '--deps', 'mac', '--delete_unversioned_trees', '--jobs', '1'], 950 '--deps', 'mac', '--delete_unversioned_trees', '--jobs', '1'],
971 [ 951 [ 'running', 'running', 'deleting'],
972 'running',
973 ('running', self.root_dir + '/src/repo2/repo3'),
974 'running',
975 ('running', self.root_dir + '/src/repo4'),
976 expect3,
977 'deleting',
978 ],
979 untangle=True) 952 untangle=True)
980 tree = self.mangle_git_tree(('repo_1@1', 'src'), 953 tree = self.mangle_git_tree(('repo_1@1', 'src'),
981 ('repo_2@2', 'src/repo2'), 954 ('repo_2@2', 'src/repo2'),
982 ('repo_3@1', 'src/repo2/repo3'), 955 ('repo_3@1', 'src/repo2/repo3'),
983 ('repo_4@2', 'src/repo4')) 956 ('repo_4@2', 'src/repo4'))
984 tree['src/git_hooked2'] = 'git_hooked2' 957 tree['src/git_hooked2'] = 'git_hooked2'
985 self.assertTree(tree) 958 self.assertTree(tree)
986 # Test incremental sync: delete-unversioned_trees isn't there. 959 # Test incremental sync: delete-unversioned_trees isn't there.
987 expect4 = os.path.join(self.root_dir, 'src', 'repo2', 'repo3')
988 expect5 = os.path.join(self.root_dir, 'src', 'repo4')
989 self.parseGclient( 960 self.parseGclient(
990 ['sync', '--deps', 'mac', '--jobs', '8'], 961 ['sync', '--deps', 'mac', '--jobs', '8'],
991 ['running', ('running', self.root_dir + '/src/repo2/repo_renamed'), 962 ['running', 'running', 'running'],
992 'running', 'running', ('running', expect4), ('running', expect5)],
993 untangle=True) 963 untangle=True)
994 tree = self.mangle_git_tree(('repo_1@2', 'src'), 964 tree = self.mangle_git_tree(('repo_1@2', 'src'),
995 ('repo_2@1', 'src/repo2'), 965 ('repo_2@1', 'src/repo2'),
996 ('repo_3@1', 'src/repo2/repo3'), 966 ('repo_3@1', 'src/repo2/repo3'),
997 ('repo_3@2', 'src/repo2/repo_renamed'), 967 ('repo_3@2', 'src/repo2/repo_renamed'),
998 ('repo_4@2', 'src/repo4')) 968 ('repo_4@2', 'src/repo4'))
999 tree['src/git_hooked1'] = 'git_hooked1' 969 tree['src/git_hooked1'] = 'git_hooked1'
1000 tree['src/git_hooked2'] = 'git_hooked2' 970 tree['src/git_hooked2'] = 'git_hooked2'
1001 self.assertTree(tree) 971 self.assertTree(tree)
1002 972
(...skipping 22 matching lines...) Expand all
1025 tree['src/git_hooked1'] = 'git_hooked1' 995 tree['src/git_hooked1'] = 'git_hooked1'
1026 tree['src/git_hooked2'] = 'git_hooked2' 996 tree['src/git_hooked2'] = 'git_hooked2'
1027 self.assertTree(tree) 997 self.assertTree(tree)
1028 998
1029 def testPreDepsHooks(self): 999 def testPreDepsHooks(self):
1030 if not self.enabled: 1000 if not self.enabled:
1031 return 1001 return
1032 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) 1002 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src'])
1033 expectation = [ 1003 expectation = [
1034 ('running', self.root_dir), # git clone repo_5 1004 ('running', self.root_dir), # git clone repo_5
1035 ('running', self.root_dir + '/src'), # git checkout src
1036 ('running', self.root_dir), # pre-deps hook 1005 ('running', self.root_dir), # pre-deps hook
1037 ('running', self.root_dir), # git clone repo_1 1006 ('running', self.root_dir), # git clone repo_1
1038 ('running', self.root_dir + '/src/repo1'), # git checkout repo1
1039 ('running', self.root_dir), # git clone repo_1 1007 ('running', self.root_dir), # git clone repo_1
1040 ('running', self.root_dir + '/src/repo2'), # git checkout repo2
1041 ] 1008 ]
1042 out = self.parseGclient(['sync', '--deps', 'mac', '--jobs=1', 1009 out = self.parseGclient(['sync', '--deps', 'mac', '--jobs=1',
1043 '--revision', 'src@' + self.githash('repo_5', 2)], 1010 '--revision', 'src@' + self.githash('repo_5', 2)],
1044 expectation) 1011 expectation)
1045 self.assertEquals(2, len(out[2])) 1012 self.assertEquals(2, len(out[1]))
1046 self.assertEquals('pre-deps hook', out[2][1]) 1013 self.assertEquals('pre-deps hook', out[1][1])
1047 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1014 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1048 ('repo_1@2', 'src/repo1'), 1015 ('repo_1@2', 'src/repo1'),
1049 ('repo_2@1', 'src/repo2') 1016 ('repo_2@1', 'src/repo2')
1050 ) 1017 )
1051 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' 1018 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked'
1052 self.assertTree(tree) 1019 self.assertTree(tree)
1053 1020
1054 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) 1021 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked'))
1055 1022
1056 # Pre-DEPS hooks don't run with runhooks. 1023 # Pre-DEPS hooks don't run with runhooks.
(...skipping 24 matching lines...) Expand all
1081 ('repo_2@1', 'src/repo2') 1048 ('repo_2@1', 'src/repo2')
1082 ) 1049 )
1083 self.assertTree(tree) 1050 self.assertTree(tree)
1084 1051
1085 def testPreDepsHooksError(self): 1052 def testPreDepsHooksError(self):
1086 if not self.enabled: 1053 if not self.enabled:
1087 return 1054 return
1088 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) 1055 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src'])
1089 expectated_stdout = [ 1056 expectated_stdout = [
1090 ('running', self.root_dir), # git clone repo_5 1057 ('running', self.root_dir), # git clone repo_5
1091 ('running', self.root_dir + '/src'), # git checkout src
1092 ('running', self.root_dir), # pre-deps hook 1058 ('running', self.root_dir), # pre-deps hook
1093 ('running', self.root_dir), # pre-deps hook (fails) 1059 ('running', self.root_dir), # pre-deps hook (fails)
1094 ] 1060 ]
1095 expected_stderr = ('Error: Command /usr/bin/python -c import sys; ' 1061 expected_stderr = ('Error: Command /usr/bin/python -c import sys; '
1096 'sys.exit(1) returned non-zero exit status 1 in %s\n' 1062 'sys.exit(1) returned non-zero exit status 1 in %s\n'
1097 % self.root_dir) 1063 % self.root_dir)
1098 stdout, stderr, retcode = self.gclient(['sync', '--deps', 'mac', '--jobs=1', 1064 stdout, stderr, retcode = self.gclient(['sync', '--deps', 'mac', '--jobs=1',
1099 '--revision', 1065 '--revision',
1100 'src@' + self.githash('repo_5', 3)]) 1066 'src@' + self.githash('repo_5', 3)])
1101 self.assertEquals(stderr, expected_stderr) 1067 self.assertEquals(stderr, expected_stderr)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 'custom_vars': {} 1130 'custom_vars': {}
1165 }]) 1131 }])
1166 1132
1167 # Tested in testSync. 1133 # Tested in testSync.
1168 self.gclient(['sync', '--deps', 'mac']) 1134 self.gclient(['sync', '--deps', 'mac'])
1169 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') 1135 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!')
1170 1136
1171 expected1 = ('running', os.path.join(self.root_dir, 'src')) 1137 expected1 = ('running', os.path.join(self.root_dir, 'src'))
1172 expected2 = ('running', os.path.join(expected1[1], 'repo2')) 1138 expected2 = ('running', os.path.join(expected1[1], 'repo2'))
1173 expected3 = ('running', os.path.join(expected2[1], 'repo_renamed')) 1139 expected3 = ('running', os.path.join(expected2[1], 'repo_renamed'))
1174 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], 1140 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], [])
1175 [expected1, expected2, expected3])
1176 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned 1141 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
1177 # files. 1142 # files.
1178 self.assertEquals(3, len(out)) 1143 self.assertEquals(0, len(out))
1179 1144
1180 # Revert implies --force implies running hooks without looking at pattern 1145 # Revert implies --force implies running hooks without looking at pattern
1181 # matching. For each expected path, 'git reset' and 'git clean' are run, so 1146 # matching. For each expected path, 'git reset' and 'git clean' are run, so
1182 # there should be two results for each. The last two results should reflect 1147 # there should be two results for each. The last two results should reflect
1183 # writing git_hooked1 and git_hooked2. 1148 # 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'.
1184 expected4 = ('running', self.root_dir) 1150 expected4 = ('running', self.root_dir)
1185 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], 1151 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
1186 [expected1, expected1, 1152 [expected1, expected1,
1187 expected2, expected2, 1153 expected2, expected2,
1188 expected3, expected3, 1154 expected3,
1189 expected4, expected4]) 1155 expected4, expected4])
1190 self.assertEquals(8, len(out)) 1156 self.assertEquals(7, len(out))
1191 tree = self.mangle_git_tree(('repo_1@3', 'src'), 1157 tree = self.mangle_git_tree(('repo_1@3', 'src'),
1192 ('repo_2@1', 'src/repo2'), 1158 ('repo_2@1', 'src/repo2'),
1193 ('repo_3@2', 'src/repo2/repo_renamed')) 1159 ('repo_3@2', 'src/repo2/repo_renamed'))
1194 tree['src/git_hooked1'] = 'git_hooked1' 1160 tree['src/git_hooked1'] = 'git_hooked1'
1195 tree['src/git_hooked2'] = 'git_hooked2' 1161 tree['src/git_hooked2'] = 'git_hooked2'
1196 self.assertTree(tree) 1162 self.assertTree(tree)
1197 1163
1198 # Make a new commit object in the origin repo, to force reset to fetch. 1164 # Make a new commit object in the origin repo, to force reset to fetch.
1199 self.FAKE_REPOS._commit_git('repo_2', { # pylint: disable=W0212 1165 self.FAKE_REPOS._commit_git('repo_2', { # pylint: disable=W0212
1200 'origin': 'git/repo_2@3\n', 1166 'origin': 'git/repo_2@3\n',
1201 }) 1167 })
1202 1168
1203 self.gclient(['config', '--spec', config_template % { 1169 self.gclient(['config', '--spec', config_template % {
1204 'git_base': self.git_base, 1170 'git_base': self.git_base,
1205 'custom_vars': {'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0] } 1171 'custom_vars': {'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0] }
1206 }]) 1172 }])
1207 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'], 1173 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
1208 [expected1, expected1, 1174 [expected1, expected1,
1209 expected2, expected2, 1175 expected2, expected2,
1210 expected3, expected3, 1176 expected3,
1211 expected4, expected4]) 1177 expected4, expected4])
1212 self.assertEquals(8, len(out)) 1178 self.assertEquals(7, len(out))
1213 tree = self.mangle_git_tree(('repo_1@3', 'src'), 1179 tree = self.mangle_git_tree(('repo_1@3', 'src'),
1214 ('repo_2@3', 'src/repo2'), 1180 ('repo_2@3', 'src/repo2'),
1215 ('repo_3@2', 'src/repo2/repo_renamed')) 1181 ('repo_3@2', 'src/repo2/repo_renamed'))
1216 tree['src/git_hooked1'] = 'git_hooked1' 1182 tree['src/git_hooked1'] = 'git_hooked1'
1217 tree['src/git_hooked2'] = 'git_hooked2' 1183 tree['src/git_hooked2'] = 'git_hooked2'
1218 self.assertTree(tree) 1184 self.assertTree(tree)
1219 1185
1220 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1']) 1186 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1'])
1221 out = results[0].splitlines(False) 1187 out = results[0].splitlines(False)
1222 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned 1188 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
1223 # files. 1189 # files.
1224 self.assertEquals(6, len(out)) 1190 self.assertEquals(0, len(out))
1225 1191
1226 class GClientSmokeBoth(GClientSmokeBase): 1192 class GClientSmokeBoth(GClientSmokeBase):
1227 def setUp(self): 1193 def setUp(self):
1228 super(GClientSmokeBoth, self).setUp() 1194 super(GClientSmokeBoth, self).setUp()
1229 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git() 1195 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git()
1230 1196
1231 def testMultiSolutions(self): 1197 def testMultiSolutions(self):
1232 if not self.enabled: 1198 if not self.enabled:
1233 return 1199 return
1234 self.gclient(['config', '--spec', 1200 self.gclient(['config', '--spec',
1235 'solutions=[' 1201 'solutions=['
1236 '{"name": "src",' 1202 '{"name": "src",'
1237 ' "url": "' + self.svn_base + 'trunk/src/"},' 1203 ' "url": "' + self.svn_base + 'trunk/src/"},'
1238 '{"name": "src-git",' 1204 '{"name": "src-git",'
1239 '"url": "' + self.git_base + 'repo_1"}]']) 1205 '"url": "' + self.git_base + 'repo_1"}]'])
1240 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'], 1206 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'],
1241 ['running', 1207 ['running', 'running', 'running',
1242 'running', ('running', self.root_dir + '/src-git'),
1243 'running',
1244 # This is due to the way svn update is called for a single 1208 # This is due to the way svn update is called for a single
1245 # file when File() is used in a DEPS file. 1209 # file when File() is used in a DEPS file.
1246 ('running', self.root_dir + '/src/file/other'), 1210 ('running', self.root_dir + '/src/file/other'),
1247 'running', 'running', 'running', 1211 'running', 'running', 'running', 'running',
1248 'running', ('running', self.root_dir + '/src/repo2'), 1212 'running', 'running', 'running', 'running'])
1249 'running', ('running', self.root_dir + '/src/repo2/repo_renamed'),
1250 'running', 'running', 'running'])
1251 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), 1213 tree = self.mangle_git_tree(('repo_1@2', 'src-git'),
1252 ('repo_2@1', 'src/repo2'), 1214 ('repo_2@1', 'src/repo2'),
1253 ('repo_3@2', 'src/repo2/repo_renamed')) 1215 ('repo_3@2', 'src/repo2/repo_renamed'))
1254 tree.update(self.mangle_svn_tree( 1216 tree.update(self.mangle_svn_tree(
1255 ('trunk/src@2', 'src'), 1217 ('trunk/src@2', 'src'),
1256 ('trunk/third_party/foo@1', 'src/third_party/foo'), 1218 ('trunk/third_party/foo@1', 'src/third_party/foo'),
1257 ('trunk/other@2', 'src/other'))) 1219 ('trunk/other@2', 'src/other')))
1258 tree['src/file/other/DEPS'] = ( 1220 tree['src/file/other/DEPS'] = (
1259 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) 1221 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
1260 tree['src/git_hooked1'] = 'git_hooked1' 1222 tree['src/git_hooked1'] = 'git_hooked1'
(...skipping 10 matching lines...) Expand all
1271 ' "url": "' + self.svn_base + 'trunk/src/"},' 1233 ' "url": "' + self.svn_base + 'trunk/src/"},'
1272 '{"name": "src-git",' 1234 '{"name": "src-git",'
1273 '"url": "' + self.git_base + 'repo_1"}]']) 1235 '"url": "' + self.git_base + 'repo_1"}]'])
1274 # There is no guarantee that the ordering will be consistent. 1236 # There is no guarantee that the ordering will be consistent.
1275 (stdout, stderr, returncode) = self.gclient( 1237 (stdout, stderr, returncode) = self.gclient(
1276 ['sync', '--deps', 'mac', '--jobs', '8']) 1238 ['sync', '--deps', 'mac', '--jobs', '8'])
1277 stdout = self.untangle(stdout) 1239 stdout = self.untangle(stdout)
1278 self.checkString('', stderr) 1240 self.checkString('', stderr)
1279 self.assertEquals(0, returncode) 1241 self.assertEquals(0, returncode)
1280 results = self.splitBlock(stdout) 1242 results = self.splitBlock(stdout)
1281 self.assertEquals(15, len(results)) 1243 self.assertEquals(12, len(results))
1282 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), 1244 tree = self.mangle_git_tree(('repo_1@2', 'src-git'),
1283 ('repo_2@1', 'src/repo2'), 1245 ('repo_2@1', 'src/repo2'),
1284 ('repo_3@2', 'src/repo2/repo_renamed')) 1246 ('repo_3@2', 'src/repo2/repo_renamed'))
1285 tree.update(self.mangle_svn_tree( 1247 tree.update(self.mangle_svn_tree(
1286 ('trunk/src@2', 'src'), 1248 ('trunk/src@2', 'src'),
1287 ('trunk/third_party/foo@1', 'src/third_party/foo'), 1249 ('trunk/third_party/foo@1', 'src/third_party/foo'),
1288 ('trunk/other@2', 'src/other'))) 1250 ('trunk/other@2', 'src/other')))
1289 tree['src/file/other/DEPS'] = ( 1251 tree['src/file/other/DEPS'] = (
1290 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) 1252 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
1291 tree['src/git_hooked1'] = 'git_hooked1' 1253 tree['src/git_hooked1'] = 'git_hooked1'
1292 tree['src/git_hooked2'] = 'git_hooked2' 1254 tree['src/git_hooked2'] = 'git_hooked2'
1293 tree['src/svn_hooked1'] = 'svn_hooked1' 1255 tree['src/svn_hooked1'] = 'svn_hooked1'
1294 self.assertTree(tree) 1256 self.assertTree(tree)
1295 1257
1296 def testMultiSolutionsMultiRev(self): 1258 def testMultiSolutionsMultiRev(self):
1297 if not self.enabled: 1259 if not self.enabled:
1298 return 1260 return
1299 self.gclient(['config', '--spec', 1261 self.gclient(['config', '--spec',
1300 'solutions=[' 1262 'solutions=['
1301 '{"name": "src",' 1263 '{"name": "src",'
1302 ' "url": "' + self.svn_base + 'trunk/src/"},' 1264 ' "url": "' + self.svn_base + 'trunk/src/"},'
1303 '{"name": "src-git",' 1265 '{"name": "src-git",'
1304 '"url": "' + self.git_base + 'repo_1"}]']) 1266 '"url": "' + self.git_base + 'repo_1"}]'])
1305 self.parseGclient( 1267 self.parseGclient(
1306 ['sync', '--deps', 'mac', '--jobs', '1', '--revision', '1', 1268 ['sync', '--deps', 'mac', '--jobs', '1', '--revision', '1',
1307 '-r', 'src-git@' + self.githash('repo_1', 1)], 1269 '-r', 'src-git@' + self.githash('repo_1', 1)],
1308 ['running', 1270 ['running', 'running', 'running', 'running', 'running',
1309 'running', ('running', self.root_dir + '/src-git'), 1271 'running', 'running', 'running'],
1310 'running', 'running', 'running',
1311 'running', ('running', self.root_dir + '/src/repo2'),
1312 'running', ('running', self.root_dir + '/src/repo2/repo3'),
1313 'running', ('running', self.root_dir + '/src/repo4')],
1314 expected_stderr= 1272 expected_stderr=
1315 'You must specify the full solution name like --revision src@1\n' 1273 'You must specify the full solution name like --revision src@1\n'
1316 'when you have multiple solutions setup in your .gclient file.\n' 1274 'when you have multiple solutions setup in your .gclient file.\n'
1317 'Other solutions present are: src-git.\n') 1275 'Other solutions present are: src-git.\n')
1318 tree = self.mangle_git_tree(('repo_1@1', 'src-git'), 1276 tree = self.mangle_git_tree(('repo_1@1', 'src-git'),
1319 ('repo_2@2', 'src/repo2'), 1277 ('repo_2@2', 'src/repo2'),
1320 ('repo_3@1', 'src/repo2/repo3'), 1278 ('repo_3@1', 'src/repo2/repo3'),
1321 ('repo_4@2', 'src/repo4')) 1279 ('repo_4@2', 'src/repo4'))
1322 tree.update(self.mangle_svn_tree( 1280 tree.update(self.mangle_svn_tree(
1323 ('trunk/src@1', 'src'), 1281 ('trunk/src@1', 'src'),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 1455
1498 if '-c' in sys.argv: 1456 if '-c' in sys.argv:
1499 COVERAGE = True 1457 COVERAGE = True
1500 sys.argv.remove('-c') 1458 sys.argv.remove('-c')
1501 if os.path.exists('.coverage'): 1459 if os.path.exists('.coverage'):
1502 os.remove('.coverage') 1460 os.remove('.coverage')
1503 os.environ['COVERAGE_FILE'] = os.path.join( 1461 os.environ['COVERAGE_FILE'] = os.path.join(
1504 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1462 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1505 '.coverage') 1463 '.coverage')
1506 unittest.main() 1464 unittest.main()
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698