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

Side by Side Diff: tests/gclient_smoketest.py

Issue 2865039: Improve testing with File() keyword, found a few bugs along the way (Closed)
Patch Set: Update expectations instead of disabling a check Created 10 years, 5 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
« no previous file with comments | « tests/fake_repos.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/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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 class GClientSmokeSVN(GClientSmokeBase): 197 class GClientSmokeSVN(GClientSmokeBase):
198 def setUp(self): 198 def setUp(self):
199 GClientSmokeBase.setUp(self) 199 GClientSmokeBase.setUp(self)
200 self.FAKE_REPOS.setUpSVN() 200 self.FAKE_REPOS.setUpSVN()
201 201
202 def testSync(self): 202 def testSync(self):
203 # TODO(maruel): safesync. 203 # TODO(maruel): safesync.
204 self.gclient(['config', self.svn_base + 'trunk/src/']) 204 self.gclient(['config', self.svn_base + 'trunk/src/'])
205 # Test unversioned checkout. 205 # Test unversioned checkout.
206 self.parseGclient(['sync', '--deps', 'mac'], 206 self.parseGclient(['sync', '--deps', 'mac'],
207 ['running', 'running', 'running', 'running']) 207 ['running', 'running',
208 # This is due to the way svn update is called for a
209 # single file when File() is used in a DEPS file.
210 ('running', self.root_dir + '/src/file/foo'),
211 'running', 'running', 'running', 'running'])
208 tree = self.mangle_svn_tree( 212 tree = self.mangle_svn_tree(
209 ('trunk/src@2', 'src'), 213 ('trunk/src@2', 'src'),
210 ('trunk/third_party/foo@1', 'src/third_party/foo'), 214 ('trunk/third_party/foo@1', 'src/third_party/foo'),
211 ('trunk/other@2', 'src/other')) 215 ('trunk/other@2', 'src/other'))
216 tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
212 tree['src/svn_hooked1'] = 'svn_hooked1' 217 tree['src/svn_hooked1'] = 'svn_hooked1'
213 self.assertTree(tree) 218 self.assertTree(tree)
214 219
215 # Manually remove svn_hooked1 before synching to make sure it's not 220 # Manually remove svn_hooked1 before synching to make sure it's not
216 # recreated. 221 # recreated.
217 os.remove(join(self.root_dir, 'src', 'svn_hooked1')) 222 os.remove(join(self.root_dir, 'src', 'svn_hooked1'))
218 223
219 # Test incremental versioned sync: sync backward. 224 # Test incremental versioned sync: sync backward.
220 self.parseGclient(['sync', '--revision', 'src@1', '--deps', 'mac', 225 self.parseGclient(['sync', '--revision', 'src@1', '--deps', 'mac',
221 '--delete_unversioned_trees'], 226 '--delete_unversioned_trees'],
222 ['running', 'running', 'running', 'running', 'deleting']) 227 ['running', 'running', 'running', 'running', 'deleting'])
223 tree = self.mangle_svn_tree( 228 tree = self.mangle_svn_tree(
224 ('trunk/src@1', 'src'), 229 ('trunk/src@1', 'src'),
225 ('trunk/third_party/foo@2', 'src/third_party/fpp'), 230 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
226 ('trunk/other@1', 'src/other'), 231 ('trunk/other@1', 'src/other'),
227 ('trunk/third_party/foo@2', 'src/third_party/prout')) 232 ('trunk/third_party/foo@2', 'src/third_party/prout'))
233 tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
228 self.assertTree(tree) 234 self.assertTree(tree)
229 # Test incremental sync: delete-unversioned_trees isn't there. 235 # Test incremental sync: delete-unversioned_trees isn't there.
230 self.parseGclient(['sync', '--deps', 'mac'], 236 self.parseGclient(['sync', '--deps', 'mac'],
231 ['running', 'running', 'running', 'running']) 237 ['running', 'running', 'running', 'running', 'running'])
232 tree = self.mangle_svn_tree( 238 tree = self.mangle_svn_tree(
233 ('trunk/src@2', 'src'), 239 ('trunk/src@2', 'src'),
234 ('trunk/third_party/foo@2', 'src/third_party/fpp'), 240 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
235 ('trunk/third_party/foo@1', 'src/third_party/foo'), 241 ('trunk/third_party/foo@1', 'src/third_party/foo'),
236 ('trunk/other@2', 'src/other'), 242 ('trunk/other@2', 'src/other'),
237 ('trunk/third_party/foo@2', 'src/third_party/prout')) 243 ('trunk/third_party/foo@2', 'src/third_party/prout'))
244 tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
238 tree['src/svn_hooked1'] = 'svn_hooked1' 245 tree['src/svn_hooked1'] = 'svn_hooked1'
239 self.assertTree(tree) 246 self.assertTree(tree)
240 247
241 def testSyncIgnoredSolutionName(self): 248 def testSyncIgnoredSolutionName(self):
242 """TODO(maruel): This will become an error soon.""" 249 """TODO(maruel): This will become an error soon."""
243 self.gclient(['config', self.svn_base + 'trunk/src/']) 250 self.gclient(['config', self.svn_base + 'trunk/src/'])
244 results = self.gclient(['sync', '--deps', 'mac', '-r', 'invalid@1']) 251 results = self.gclient(['sync', '--deps', 'mac', '-r', 'invalid@1'])
245 self.checkBlock(results[0], ['running', 'running', 'running', 'running']) 252 self.checkBlock(results[0], [
253 'running', 'running',
254 # This is due to the way svn update is called for a single file when
255 # File() is used in a DEPS file.
256 ('running', self.root_dir + '/src/file/foo'),
257 'running', 'running', 'running', 'running'])
246 self.checkString('Please fix your script, having invalid --revision flags ' 258 self.checkString('Please fix your script, having invalid --revision flags '
247 'will soon considered an error.\n', results[1]) 259 'will soon considered an error.\n', results[1])
248 self.assertEquals(0, results[2]) 260 self.assertEquals(0, results[2])
249 tree = self.mangle_svn_tree( 261 tree = self.mangle_svn_tree(
250 ('trunk/src@2', 'src'), 262 ('trunk/src@2', 'src'),
251 ('trunk/third_party/foo@1', 'src/third_party/foo'), 263 ('trunk/third_party/foo@1', 'src/third_party/foo'),
252 ('trunk/other@2', 'src/other')) 264 ('trunk/other@2', 'src/other'))
265 tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
253 tree['src/svn_hooked1'] = 'svn_hooked1' 266 tree['src/svn_hooked1'] = 'svn_hooked1'
254 self.assertTree(tree) 267 self.assertTree(tree)
255 268
256 def testSyncNoSolutionName(self): 269 def testSyncNoSolutionName(self):
257 # When no solution name is provided, gclient uses the first solution listed. 270 # When no solution name is provided, gclient uses the first solution listed.
258 self.gclient(['config', self.svn_base + 'trunk/src/']) 271 self.gclient(['config', self.svn_base + 'trunk/src/'])
259 self.parseGclient(['sync', '--deps', 'mac', '-r', '1'], 272 self.parseGclient(['sync', '--deps', 'mac', '-r', '1'],
260 ['running', 'running', 'running', 'running']) 273 ['running', 'running', 'running', 'running'])
261 tree = self.mangle_svn_tree( 274 tree = self.mangle_svn_tree(
262 ('trunk/src@1', 'src'), 275 ('trunk/src@1', 'src'),
263 ('trunk/third_party/foo@2', 'src/third_party/fpp'), 276 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
264 ('trunk/other@1', 'src/other'), 277 ('trunk/other@1', 'src/other'),
265 ('trunk/third_party/foo@2', 'src/third_party/prout')) 278 ('trunk/third_party/foo@2', 'src/third_party/prout'))
266 self.assertTree(tree) 279 self.assertTree(tree)
267 280
268 def testRevertAndStatus(self): 281 def testRevertAndStatus(self):
269 self.gclient(['config', self.svn_base + 'trunk/src/']) 282 self.gclient(['config', self.svn_base + 'trunk/src/'])
270 # Tested in testSync. 283 # Tested in testSync.
271 self.gclient(['sync', '--deps', 'mac']) 284 self.gclient(['sync', '--deps', 'mac'])
272 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') 285 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!')
273 286
274 out = self.parseGclient(['status', '--deps', 'mac'], 287 out = self.parseGclient(['status', '--deps', 'mac'],
275 [['running', join(self.root_dir, 'src')], 288 [['running', join(self.root_dir, 'src')],
276 ['running', join(self.root_dir, 'src', 'other')]]) 289 ['running', join(self.root_dir, 'src', 'other')]])
277 out = self.svnBlockCleanup(out) 290 out = self.svnBlockCleanup(out)
278 self.checkString('other', out[0][1]) 291 self.checkString('file', out[0][1])
279 self.checkString('svn_hooked1', out[0][2]) 292 self.checkString('other', out[0][2])
280 self.checkString(join('third_party', 'foo'), out[0][3]) 293 self.checkString('svn_hooked1', out[0][3])
294 self.checkString(join('third_party', 'foo'), out[0][4])
281 self.checkString('hi', out[1][1]) 295 self.checkString('hi', out[1][1])
282 self.assertEquals(4, len(out[0])) 296 self.assertEquals(5, len(out[0]))
283 self.assertEquals(2, len(out[1])) 297 self.assertEquals(2, len(out[1]))
284 298
285 # Revert implies --force implies running hooks without looking at pattern 299 # Revert implies --force implies running hooks without looking at pattern
286 # matching. 300 # matching.
287 results = self.gclient(['revert', '--deps', 'mac']) 301 results = self.gclient(['revert', '--deps', 'mac'])
288 out = self.splitBlock(results[0]) 302 out = self.splitBlock(results[0])
289 # src, src/other is missing, src/other, src/third_party/foo is missing, 303 # src, src/other is missing, src/other, src/third_party/foo is missing,
290 # src/third_party/foo, 2 svn hooks. 304 # src/third_party/foo, 2 svn hooks, 3 related to File().
291 self.assertEquals(7, len(out)) 305 self.assertEquals(10, len(out))
292 self.checkString('', results[1]) 306 self.checkString('', results[1])
293 self.assertEquals(0, results[2]) 307 self.assertEquals(0, results[2])
294 tree = self.mangle_svn_tree( 308 tree = self.mangle_svn_tree(
295 ('trunk/src@2', 'src'), 309 ('trunk/src@2', 'src'),
296 ('trunk/third_party/foo@1', 'src/third_party/foo'), 310 ('trunk/third_party/foo@1', 'src/third_party/foo'),
297 ('trunk/other@2', 'src/other')) 311 ('trunk/other@2', 'src/other'))
312 tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
298 tree['src/svn_hooked1'] = 'svn_hooked1' 313 tree['src/svn_hooked1'] = 'svn_hooked1'
299 tree['src/svn_hooked2'] = 'svn_hooked2' 314 tree['src/svn_hooked2'] = 'svn_hooked2'
300 self.assertTree(tree) 315 self.assertTree(tree)
301 316
302 out = self.parseGclient(['status', '--deps', 'mac'], 317 out = self.parseGclient(['status', '--deps', 'mac'],
303 [['running', join(self.root_dir, 'src')]]) 318 [['running', join(self.root_dir, 'src')]])
304 out = self.svnBlockCleanup(out) 319 out = self.svnBlockCleanup(out)
305 self.checkString('other', out[0][1]) 320 self.checkString('file', out[0][1])
306 self.checkString('svn_hooked1', out[0][2]) 321 self.checkString('other', out[0][2])
307 self.checkString('svn_hooked2', out[0][3]) 322 self.checkString('svn_hooked1', out[0][3])
308 self.checkString(join('third_party', 'foo'), out[0][4]) 323 self.checkString('svn_hooked2', out[0][4])
309 self.assertEquals(5, len(out[0])) 324 self.checkString(join('third_party', 'foo'), out[0][5])
325 self.assertEquals(6, len(out[0]))
326 self.assertEquals(1, len(out))
310 327
311 def testRevertAndStatusDepsOs(self): 328 def testRevertAndStatusDepsOs(self):
312 self.gclient(['config', self.svn_base + 'trunk/src/']) 329 self.gclient(['config', self.svn_base + 'trunk/src/'])
313 # Tested in testSync. 330 # Tested in testSync.
314 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) 331 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1'])
315 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') 332 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!')
316 333
317 # Without --verbose, gclient won't output the directories without 334 # Without --verbose, gclient won't output the directories without
318 # modification. 335 # modification.
319 out = self.parseGclient(['status', '--deps', 'mac'], 336 out = self.parseGclient(['status', '--deps', 'mac'],
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 return 602 return
586 self.gclient(['config', '--spec', 603 self.gclient(['config', '--spec',
587 'solutions=[' 604 'solutions=['
588 '{"name": "src",' 605 '{"name": "src",'
589 ' "url": "' + self.svn_base + 'trunk/src/"},' 606 ' "url": "' + self.svn_base + 'trunk/src/"},'
590 '{"name": "src-git",' 607 '{"name": "src-git",'
591 '"url": "' + self.git_base + 'repo_1"}]']) 608 '"url": "' + self.git_base + 'repo_1"}]'])
592 results = self.gclient(['sync', '--deps', 'mac']) 609 results = self.gclient(['sync', '--deps', 'mac'])
593 # 3x svn checkout, 3x run hooks 610 # 3x svn checkout, 3x run hooks
594 self.checkBlock(results[0], 611 self.checkBlock(results[0],
595 ['running', 'running', 'running', 'running', 'running', 612 ['running', 'running',
613 # This is due to the way svn update is called for a single
614 # file when File() is used in a DEPS file.
615 ('running', self.root_dir + '/src/file/foo'),
616 'running', 'running', 'running', 'running', 'running',
596 'running', 'running']) 617 'running', 'running'])
597 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to 618 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to
598 # new branch \'hash\''. 619 # new branch \'hash\''.
599 #self.checkString('', results[1]) 620 #self.checkString('', results[1])
600 self.assertEquals(0, results[2]) 621 self.assertEquals(0, results[2])
601 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), 622 tree = self.mangle_git_tree(('repo_1@2', 'src-git'),
602 ('repo_2@1', 'src/repo2'), 623 ('repo_2@1', 'src/repo2'),
603 ('repo_3@2', 'src/repo2/repo_renamed')) 624 ('repo_3@2', 'src/repo2/repo_renamed'))
604 tree.update(self.mangle_svn_tree( 625 tree.update(self.mangle_svn_tree(
605 ('trunk/src@2', 'src'), 626 ('trunk/src@2', 'src'),
606 ('trunk/third_party/foo@1', 'src/third_party/foo'), 627 ('trunk/third_party/foo@1', 'src/third_party/foo'),
607 ('trunk/other@2', 'src/other'))) 628 ('trunk/other@2', 'src/other')))
629 tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
608 tree['src/git_hooked1'] = 'git_hooked1' 630 tree['src/git_hooked1'] = 'git_hooked1'
609 tree['src/git_hooked2'] = 'git_hooked2' 631 tree['src/git_hooked2'] = 'git_hooked2'
610 tree['src/svn_hooked1'] = 'svn_hooked1' 632 tree['src/svn_hooked1'] = 'svn_hooked1'
611 tree['src/svn_hooked2'] = 'svn_hooked2' 633 tree['src/svn_hooked2'] = 'svn_hooked2'
612 self.assertTree(tree) 634 self.assertTree(tree)
613 635
614 def testMultiSolutionsMultiRev(self): 636 def testMultiSolutionsMultiRev(self):
615 if not self.enabled: 637 if not self.enabled:
616 return 638 return
617 self.gclient(['config', '--spec', 639 self.gclient(['config', '--spec',
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 return 690 return
669 self.gclient(['config', '--spec', 691 self.gclient(['config', '--spec',
670 'solutions=[' 692 'solutions=['
671 '{"name": "src",' 693 '{"name": "src",'
672 ' "url": "' + self.svn_base + 'trunk/src/"},' 694 ' "url": "' + self.svn_base + 'trunk/src/"},'
673 '{"name": "src-git",' 695 '{"name": "src-git",'
674 '"url": "' + self.git_base + 'repo_1"}]']) 696 '"url": "' + self.git_base + 'repo_1"}]'])
675 self.gclient(['sync', '--deps', 'mac']) 697 self.gclient(['sync', '--deps', 'mac'])
676 results = self.gclient(['recurse', 'sh', '-c', 698 results = self.gclient(['recurse', 'sh', '-c',
677 'echo $GCLIENT_SCM,$GCLIENT_URL,`pwd`']) 699 'echo $GCLIENT_SCM,$GCLIENT_URL,`pwd`'])
678 700
679 entries = [tuple(line.split(',')) 701 entries = [tuple(line.split(','))
680 for line in results[0].strip().split('\n')] 702 for line in results[0].strip().split('\n')]
681 logging.debug(entries) 703 logging.debug(entries)
682 704
683 bases = {'svn': self.svn_base, 'git': self.git_base} 705 bases = {'svn': self.svn_base, 'git': self.git_base}
684 expected_source = [ 706 expected_source = [
685 ('svn', 'trunk/src/', 'src'), 707 ('svn', 'trunk/src/', 'src'),
686 ('git', 'repo_1', 'src-git'), 708 ('git', 'repo_1', 'src-git'),
687 ('svn', 'trunk/other', 'src/other'), 709 ('svn', 'trunk/other', 'src/other'),
688 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), 710 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'),
689 ('git', 'repo_3', 'src/repo2/repo_renamed'), 711 ('git', 'repo_3', 'src/repo2/repo_renamed'),
690 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), 712 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'),
691 ] 713 ]
692 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) 714 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path))
693 for (scm, url, path) in expected_source] 715 for (scm, url, path) in expected_source]
694 716
695 self.assertEquals(sorted(entries), sorted(expected)) 717 self.assertEquals(sorted(entries), sorted(expected))
696 718
697 719
698 if __name__ == '__main__': 720 if __name__ == '__main__':
699 if '-c' in sys.argv: 721 if '-c' in sys.argv:
700 COVERAGE = True 722 COVERAGE = True
701 sys.argv.remove('-c') 723 sys.argv.remove('-c')
702 if os.path.exists('.coverage'): 724 if os.path.exists('.coverage'):
703 os.remove('.coverage') 725 os.remove('.coverage')
704 os.environ['COVERAGE_FILE'] = os.path.join( 726 os.environ['COVERAGE_FILE'] = os.path.join(
705 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 727 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
706 '.coverage') 728 '.coverage')
707 unittest.main() 729 unittest.main()
OLDNEW
« no previous file with comments | « tests/fake_repos.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698