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

Side by Side Diff: tests/gclient_smoketest.py

Issue 165443004: Make gclient reset use GetUsableRev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Move test to its own suite Created 6 years, 10 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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 untangle=True) 993 untangle=True)
994 tree = self.mangle_git_tree(('repo_1@2', 'src'), 994 tree = self.mangle_git_tree(('repo_1@2', 'src'),
995 ('repo_2@1', 'src/repo2'), 995 ('repo_2@1', 'src/repo2'),
996 ('repo_3@1', 'src/repo2/repo3'), 996 ('repo_3@1', 'src/repo2/repo3'),
997 ('repo_3@2', 'src/repo2/repo_renamed'), 997 ('repo_3@2', 'src/repo2/repo_renamed'),
998 ('repo_4@2', 'src/repo4')) 998 ('repo_4@2', 'src/repo4'))
999 tree['src/git_hooked1'] = 'git_hooked1' 999 tree['src/git_hooked1'] = 'git_hooked1'
1000 tree['src/git_hooked2'] = 'git_hooked2' 1000 tree['src/git_hooked2'] = 'git_hooked2'
1001 self.assertTree(tree) 1001 self.assertTree(tree)
1002 1002
1003 def testRevertAndStatus(self):
1004 if not self.enabled:
1005 return
1006 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
1007 # Tested in testSync.
1008 self.gclient(['sync', '--deps', 'mac'])
1009 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!')
1010
1011 expected1 = ('running', os.path.join(self.root_dir, 'src'))
1012 expected2 = ('running', os.path.join(expected1[1], 'repo2'))
1013 expected3 = ('running', os.path.join(expected2[1], 'repo_renamed'))
1014 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'],
1015 [expected1, expected2, expected3])
1016 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
1017 # files.
1018 self.assertEquals(3, len(out))
1019
1020 # Revert implies --force implies running hooks without looking at pattern
1021 # matching. For each expected path, 'git reset' and 'git clean' are run, so
1022 # there should be two results for each. The last two results should reflect
1023 # writing git_hooked1 and git_hooked2.
1024 expected4 = ('running', self.root_dir)
1025 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
1026 [expected1, expected1,
1027 expected2, expected2,
1028 expected3, expected3,
1029 expected4, expected4])
1030 self.assertEquals(8, len(out))
1031 tree = self.mangle_git_tree(('repo_1@2', 'src'),
1032 ('repo_2@1', 'src/repo2'),
1033 ('repo_3@2', 'src/repo2/repo_renamed'))
1034 tree['src/git_hooked1'] = 'git_hooked1'
1035 tree['src/git_hooked2'] = 'git_hooked2'
1036 self.assertTree(tree)
1037
1038 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1'])
1039 out = results[0].splitlines(False)
1040 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
1041 # files.
1042 self.assertEquals(6, len(out))
1043
1044 def testRunHooks(self): 1003 def testRunHooks(self):
1045 if not self.enabled: 1004 if not self.enabled:
1046 return 1005 return
1047 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) 1006 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
1048 self.gclient(['sync', '--deps', 'mac']) 1007 self.gclient(['sync', '--deps', 'mac'])
1049 tree = self.mangle_git_tree(('repo_1@2', 'src'), 1008 tree = self.mangle_git_tree(('repo_1@2', 'src'),
1050 ('repo_2@1', 'src/repo2'), 1009 ('repo_2@1', 'src/repo2'),
1051 ('repo_3@2', 'src/repo2/repo_renamed')) 1010 ('repo_3@2', 'src/repo2/repo_renamed'))
1052 tree['src/git_hooked1'] = 'git_hooked1' 1011 tree['src/git_hooked1'] = 'git_hooked1'
1053 tree['src/git_hooked2'] = 'git_hooked2' 1012 tree['src/git_hooked2'] = 'git_hooked2'
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % 1122 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' %
1164 { 1123 {
1165 'base': self.git_base, 1124 'base': self.git_base,
1166 'hash1': self.githash('repo_1', 2), 1125 'hash1': self.githash('repo_1', 2),
1167 'hash2': self.githash('repo_2', 1), 1126 'hash2': self.githash('repo_2', 1),
1168 'hash3': self.githash('repo_3', 2), 1127 'hash3': self.githash('repo_3', 2),
1169 }) 1128 })
1170 self.check((out, '', 0), results) 1129 self.check((out, '', 0), results)
1171 1130
1172 1131
1132 class GClientSmokeGITMutates(GClientSmokeBase):
1133 """testRevertAndStatus mutates the git repo so move it to its own suite."""
1134 def setUp(self):
1135 super(GClientSmokeGITMutates, self).setUp()
1136 self.enabled = self.FAKE_REPOS.set_up_git()
1137
1138 def testRevertAndStatus(self):
1139 if not self.enabled:
1140 return
1141
1142 # Commit new change to repo to make repo_2's hash use a custom_var.
1143 cur_deps = self.FAKE_REPOS.git_hashes['repo_1'][-1][1]['DEPS']
1144 repo_2_hash = self.FAKE_REPOS.git_hashes['repo_2'][1][0][:7]
1145 new_deps = cur_deps.replace('repo_2@%s\'' % repo_2_hash,
1146 'repo_2@\' + Var(\'r2hash\')')
1147 new_deps = 'vars = {\'r2hash\': \'%s\'}\n%s' % (repo_2_hash, new_deps)
1148 self.FAKE_REPOS._commit_git('repo_1', { # pylint: disable=W0212
1149 'DEPS': new_deps,
1150 'origin': 'git/repo_1@3\n',
1151 })
1152
1153 config_template = (
1154 """solutions = [{
1155 "name" : "src",
1156 "url" : "%(git_base)srepo_1",
1157 "deps_file" : "DEPS",
1158 "managed" : True,
1159 "custom_vars" : %(custom_vars)s,
1160 }]""")
1161
1162 self.gclient(['config', '--spec', config_template % {
1163 'git_base': self.git_base,
1164 'custom_vars': {}
1165 }])
1166
1167 # Tested in testSync.
1168 self.gclient(['sync', '--deps', 'mac'])
1169 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!')
1170
1171 expected1 = ('running', os.path.join(self.root_dir, 'src'))
1172 expected2 = ('running', os.path.join(expected1[1], 'repo2'))
1173 expected3 = ('running', os.path.join(expected2[1], 'repo_renamed'))
1174 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'],
1175 [expected1, expected2, expected3])
1176 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
1177 # files.
1178 self.assertEquals(3, len(out))
1179
1180 # Revert implies --force implies running hooks without looking at pattern
1181 # 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
1183 # writing git_hooked1 and git_hooked2.
1184 expected4 = ('running', self.root_dir)
1185 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
1186 [expected1, expected1,
1187 expected2, expected2,
1188 expected3, expected3,
1189 expected4, expected4])
1190 self.assertEquals(8, len(out))
1191 tree = self.mangle_git_tree(('repo_1@3', 'src'),
1192 ('repo_2@1', 'src/repo2'),
1193 ('repo_3@2', 'src/repo2/repo_renamed'))
1194 tree['src/git_hooked1'] = 'git_hooked1'
1195 tree['src/git_hooked2'] = 'git_hooked2'
1196 self.assertTree(tree)
1197
1198 # 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
1200 'origin': 'git/repo_2@3\n',
1201 })
1202
1203 self.gclient(['config', '--spec', config_template % {
1204 'git_base': self.git_base,
1205 'custom_vars': {'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0] }
1206 }])
1207 out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
1208 [expected1, expected1,
1209 expected2, expected2,
1210 expected3, expected3,
1211 expected4, expected4])
1212 self.assertEquals(8, len(out))
1213 tree = self.mangle_git_tree(('repo_1@3', 'src'),
1214 ('repo_2@3', 'src/repo2'),
1215 ('repo_3@2', 'src/repo2/repo_renamed'))
1216 tree['src/git_hooked1'] = 'git_hooked1'
1217 tree['src/git_hooked2'] = 'git_hooked2'
1218 self.assertTree(tree)
1219
1220 results = self.gclient(['status', '--deps', 'mac', '--jobs', '1'])
1221 out = results[0].splitlines(False)
1222 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
1223 # files.
1224 self.assertEquals(6, len(out))
1225
1173 class GClientSmokeBoth(GClientSmokeBase): 1226 class GClientSmokeBoth(GClientSmokeBase):
1174 def setUp(self): 1227 def setUp(self):
1175 super(GClientSmokeBoth, self).setUp() 1228 super(GClientSmokeBoth, self).setUp()
1176 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git() 1229 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git()
1177 1230
1178 def testMultiSolutions(self): 1231 def testMultiSolutions(self):
1179 if not self.enabled: 1232 if not self.enabled:
1180 return 1233 return
1181 self.gclient(['config', '--spec', 1234 self.gclient(['config', '--spec',
1182 'solutions=[' 1235 'solutions=['
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 1497
1445 if '-c' in sys.argv: 1498 if '-c' in sys.argv:
1446 COVERAGE = True 1499 COVERAGE = True
1447 sys.argv.remove('-c') 1500 sys.argv.remove('-c')
1448 if os.path.exists('.coverage'): 1501 if os.path.exists('.coverage'):
1449 os.remove('.coverage') 1502 os.remove('.coverage')
1450 os.environ['COVERAGE_FILE'] = os.path.join( 1503 os.environ['COVERAGE_FILE'] = os.path.join(
1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1504 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1452 '.coverage') 1505 '.coverage')
1453 unittest.main() 1506 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