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

Side by Side Diff: tests/gclient_smoketest.py

Issue 1158043003: Remove most svn related testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix typo in doc Created 5 years, 6 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 | « tests/gclient_scm_test.py ('k') | tests/scm_unittest.py » ('j') | 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.
11 """ 11 """
12 12
13 import logging 13 import logging
14 import os 14 import os
15 import re 15 import re
16 import subprocess 16 import subprocess
17 import sys 17 import sys
18 import unittest 18 import unittest
19 19
20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21 sys.path.insert(0, ROOT_DIR) 21 sys.path.insert(0, ROOT_DIR)
22 22
23 from testing_support.fake_repos import join, write
24 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive, \
25 FakeRepoSkiaDEPS, FakeRepoBlinkDEPS
26
27 import gclient_utils 23 import gclient_utils
28 import scm as gclient_scm 24 import scm as gclient_scm
29
30 import subprocess2 25 import subprocess2
26 from testing_support import fake_repos
27 from testing_support.fake_repos import join, write
31 28
32 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') 29 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient')
33 COVERAGE = False 30 COVERAGE = False
34 31
35 32
36 class GClientSmokeBase(FakeReposTestBase): 33 class GClientSmokeBase(fake_repos.FakeReposTestBase):
37 def setUp(self): 34 def setUp(self):
38 super(GClientSmokeBase, self).setUp() 35 super(GClientSmokeBase, self).setUp()
39 # Make sure it doesn't try to auto update when testing! 36 # Make sure it doesn't try to auto update when testing!
40 self.env = os.environ.copy() 37 self.env = os.environ.copy()
41 self.env['DEPOT_TOOLS_UPDATE'] = '0' 38 self.env['DEPOT_TOOLS_UPDATE'] = '0'
42 39
43 def gclient(self, cmd, cwd=None): 40 def gclient(self, cmd, cwd=None):
44 if not cwd: 41 if not cwd:
45 cwd = self.root_dir 42 cwd = self.root_dir
46 if COVERAGE: 43 if COVERAGE:
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 deps = join(self.root_dir, 'src.DEPS') 291 deps = join(self.root_dir, 'src.DEPS')
295 os.mkdir(deps) 292 os.mkdir(deps)
296 write(join(deps, 'DEPS'), 293 write(join(deps, 'DEPS'),
297 'deps = { "src": "%strunk/src" }' % (self.svn_base)) 294 'deps = { "src": "%strunk/src" }' % (self.svn_base))
298 src = join(self.root_dir, 'src') 295 src = join(self.root_dir, 'src')
299 os.mkdir(src) 296 os.mkdir(src)
300 res = self.gclient(['status', '--jobs', '1'], src) 297 res = self.gclient(['status', '--jobs', '1'], src)
301 self.checkBlock(res[0], [('running', deps), ('running', src)]) 298 self.checkBlock(res[0], [('running', deps), ('running', src)])
302 299
303 300
304 class GClientSmokeSVN(GClientSmokeBase):
305 def setUp(self):
306 super(GClientSmokeSVN, self).setUp()
307 self.enabled = self.FAKE_REPOS.set_up_svn()
308
309 def testSync(self):
310 # TODO(maruel): safesync.
311 if not self.enabled:
312 return
313 self.gclient(['config', self.svn_base + 'trunk/src/'])
314 # Test unversioned checkout.
315 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'],
316 ['running', 'running',
317 # This is due to the way svn update is called for a
318 # single file when File() is used in a DEPS file.
319 ('running', os.path.join(self.root_dir, 'src', 'file', 'other')),
320 'running', 'running', 'running', 'running'])
321 tree = self.mangle_svn_tree(
322 ('trunk/src@2', 'src'),
323 ('trunk/third_party/foo@1', 'src/third_party/foo'),
324 ('trunk/other@2', 'src/other'))
325 tree['src/file/other/DEPS'] = (
326 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
327 tree['src/svn_hooked1'] = 'svn_hooked1'
328 self.assertTree(tree)
329
330 # Manually remove svn_hooked1 before synching to make sure it's not
331 # recreated.
332 os.remove(join(self.root_dir, 'src', 'svn_hooked1'))
333
334 # Test incremental versioned sync: sync backward.
335 self.parseGclient(
336 ['sync', '--revision', 'src@1', '--deps', 'mac',
337 '--delete_unversioned_trees', '--jobs', '1'],
338 ['running', 'running', 'running', 'running', 'deleting'])
339 tree = self.mangle_svn_tree(
340 ('trunk/src@1', 'src'),
341 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
342 ('trunk/other@1', 'src/other'),
343 ('trunk/third_party/foo@2', 'src/third_party/prout'))
344 tree['src/file/other/DEPS'] = (
345 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
346 self.assertTree(tree)
347 # Test incremental sync: delete-unversioned_trees isn't there.
348 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'],
349 ['running', 'running', 'running', 'running', 'running'])
350 tree = self.mangle_svn_tree(
351 ('trunk/src@2', 'src'),
352 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
353 ('trunk/third_party/foo@1', 'src/third_party/foo'),
354 ('trunk/other@2', 'src/other'),
355 ('trunk/third_party/foo@2', 'src/third_party/prout'))
356 tree['src/file/other/DEPS'] = (
357 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
358 tree['src/svn_hooked1'] = 'svn_hooked1'
359 self.assertTree(tree)
360
361 def testSyncIgnoredSolutionName(self):
362 """TODO(maruel): This will become an error soon."""
363 if not self.enabled:
364 return
365 self.gclient(['config', self.svn_base + 'trunk/src/'])
366 results = self.gclient(
367 ['sync', '--deps', 'mac', '-r', 'invalid@1', '--jobs', '1'])
368 self.checkBlock(results[0], [
369 'running', 'running',
370 # This is due to the way svn update is called for a single file when
371 # File() is used in a DEPS file.
372 ('running', os.path.join(self.root_dir, 'src', 'file', 'other')),
373 'running', 'running', 'running', 'running'])
374 self.checkString('Please fix your script, having invalid --revision flags '
375 'will soon considered an error.\n', results[1])
376 self.assertEquals(0, results[2])
377 tree = self.mangle_svn_tree(
378 ('trunk/src@2', 'src'),
379 ('trunk/third_party/foo@1', 'src/third_party/foo'),
380 ('trunk/other@2', 'src/other'))
381 tree['src/file/other/DEPS'] = (
382 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
383 tree['src/svn_hooked1'] = 'svn_hooked1'
384 self.assertTree(tree)
385
386 def testSyncNoSolutionName(self):
387 # When no solution name is provided, gclient uses the first solution listed.
388 if not self.enabled:
389 return
390 self.gclient(['config', self.svn_base + 'trunk/src/'])
391 self.parseGclient(['sync', '--deps', 'mac', '-r', '1', '--jobs', '1'],
392 ['running', 'running', 'running', 'running'])
393 tree = self.mangle_svn_tree(
394 ('trunk/src@1', 'src'),
395 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
396 ('trunk/other@1', 'src/other'),
397 ('trunk/third_party/foo@2', 'src/third_party/prout'))
398 self.assertTree(tree)
399
400 def testSyncJobs(self):
401 if not self.enabled:
402 return
403 # TODO(maruel): safesync.
404 self.gclient(['config', self.svn_base + 'trunk/src/'])
405 # Test unversioned checkout.
406 # Use --jobs 1 otherwise the order is not deterministic.
407 self.parseGclient(
408 ['sync', '--deps', 'mac', '--jobs', '1'],
409 [
410 'running',
411 'running',
412 # This is due to the way svn update is called for a
413 # single file when File() is used in a DEPS file.
414 ('running', os.path.join(self.root_dir, 'src', 'file', 'other')),
415 'running',
416 'running',
417 'running',
418 'running',
419 ],
420 untangle=True)
421 tree = self.mangle_svn_tree(
422 ('trunk/src@2', 'src'),
423 ('trunk/third_party/foo@1', 'src/third_party/foo'),
424 ('trunk/other@2', 'src/other'))
425 tree['src/file/other/DEPS'] = (
426 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
427 tree['src/svn_hooked1'] = 'svn_hooked1'
428 self.assertTree(tree)
429
430 # Manually remove svn_hooked1 before synching to make sure it's not
431 # recreated.
432 os.remove(join(self.root_dir, 'src', 'svn_hooked1'))
433
434 # Test incremental versioned sync: sync backward.
435 self.parseGclient(
436 ['sync', '--revision', 'src@1', '--deps', 'mac',
437 '--delete_unversioned_trees', '--jobs', '8'],
438 ['running', 'running', 'running', 'running', 'deleting'],
439 untangle=True)
440 tree = self.mangle_svn_tree(
441 ('trunk/src@1', 'src'),
442 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
443 ('trunk/other@1', 'src/other'),
444 ('trunk/third_party/foo@2', 'src/third_party/prout'))
445 tree['src/file/other/DEPS'] = (
446 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
447 self.assertTree(tree)
448 # Test incremental sync: delete-unversioned_trees isn't there.
449 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '8'],
450 ['running', 'running', 'running', 'running', 'running'],
451 untangle=True)
452 tree = self.mangle_svn_tree(
453 ('trunk/src@2', 'src'),
454 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
455 ('trunk/third_party/foo@1', 'src/third_party/foo'),
456 ('trunk/other@2', 'src/other'),
457 ('trunk/third_party/foo@2', 'src/third_party/prout'))
458 tree['src/file/other/DEPS'] = (
459 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
460 tree['src/svn_hooked1'] = 'svn_hooked1'
461 self.assertTree(tree)
462
463 def testSyncCustomDeps(self):
464 if not self.enabled:
465 return
466 out = (
467 'solutions = [\n'
468 ' { "name" : "src",\n'
469 ' "url" : "%(base)s/src",\n'
470 ' "custom_deps" : {\n'
471 # Remove 2 deps, change 1, add 1.
472 ' "src/other": None,\n'
473 ' "src/third_party/foo": \'%(base)s/third_party/prout\',\n'
474 ' "src/file/other": None,\n'
475 ' "new_deps": "/trunk/src/third_party",\n'
476 ' },\n'
477 ' "safesync_url": "",\n'
478 ' },\n'
479 ']\n\n' %
480 { 'base': self.svn_base + 'trunk' })
481 fileobj = open(os.path.join(self.root_dir, '.gclient'), 'w')
482 fileobj.write(out)
483 fileobj.close()
484 self.parseGclient(
485 ['sync', '--deps', 'mac', '--jobs', '1'],
486 ['running', 'running', 'running', 'running'],
487 untangle=True)
488 tree = self.mangle_svn_tree(
489 ('trunk/src@2', 'src'),
490 ('trunk/third_party/prout@2', 'src/third_party/foo'),
491 ('trunk/src/third_party@2', 'new_deps'))
492 tree['src/svn_hooked1'] = 'svn_hooked1'
493 self.assertTree(tree)
494
495 def testSyncCustomDepsNoDeps(self):
496 if not self.enabled:
497 return
498 out = (
499 'solutions = [\n'
500 # This directory has no DEPS file.
501 ' { "name" : "src/third_party",\n'
502 ' "url" : "%(base)s/src/third_party",\n'
503 ' "custom_deps" : {\n'
504 # Add 1.
505 ' "src/other": \'/trunk/other\',\n'
506 ' },\n'
507 ' "safesync_url": "",\n'
508 ' },\n'
509 ']\n\n' %
510 { 'base': self.svn_base + 'trunk' })
511 fileobj = open(os.path.join(self.root_dir, '.gclient'), 'w')
512 fileobj.write(out)
513 fileobj.close()
514 self.parseGclient(
515 ['sync', '--deps', 'mac', '--jobs', '1'],
516 ['running', 'running'],
517 untangle=True)
518 tree = self.mangle_svn_tree(
519 ('trunk/src/third_party@2', 'src/third_party'),
520 ('trunk/other@2', 'src/other'))
521 self.assertTree(tree)
522
523 def testRevertAndStatus(self):
524 if not self.enabled:
525 return
526 self.gclient(['config', self.svn_base + 'trunk/src/'])
527 # Tested in testSync.
528 self.gclient(['sync', '--deps', 'mac'])
529 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!')
530
531 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'],
532 [['running', join(self.root_dir, 'src')],
533 ['running', join(self.root_dir, 'src', 'other')]])
534 out = self.svnBlockCleanup(out)
535 self.checkString('file', out[0][1])
536 self.checkString('other', out[0][2])
537 self.checkString('svn_hooked1', out[0][3])
538 self.checkString(join('third_party', 'foo'), out[0][4])
539 self.checkString('hi', out[1][1])
540 self.assertEquals(5, len(out[0]))
541 self.assertEquals(2, len(out[1]))
542
543 # Revert implies --force implies running hooks without looking at pattern
544 # matching.
545 results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1'])
546 out = self.splitBlock(results[0])
547 # src, src/other is missing, src/other, src/third_party/foo is missing,
548 # src/third_party/foo, 2 svn hooks, 3 related to File().
549 self.assertEquals( 8, len(out))
550 self.checkString('', results[1])
551 self.assertEquals(0, results[2])
552 tree = self.mangle_svn_tree(
553 ('trunk/src@2', 'src'),
554 ('trunk/third_party/foo@1', 'src/third_party/foo'),
555 ('trunk/other@2', 'src/other'))
556 tree['src/file/other/DEPS'] = (
557 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
558 tree['src/svn_hooked1'] = 'svn_hooked1'
559 tree['src/svn_hooked2'] = 'svn_hooked2'
560 self.assertTree(tree)
561
562 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'],
563 [['running', join(self.root_dir, 'src')]])
564 out = self.svnBlockCleanup(out)
565 self.checkString('file', out[0][1])
566 self.checkString('other', out[0][2])
567 self.checkString('svn_hooked1', out[0][3])
568 self.checkString('svn_hooked2', out[0][4])
569 self.checkString(join('third_party', 'foo'), out[0][5])
570 self.assertEquals(6, len(out[0]))
571 self.assertEquals(1, len(out))
572
573 def testRevertAndStatusDepsOs(self):
574 if not self.enabled:
575 return
576 self.gclient(['config', self.svn_base + 'trunk/src/'])
577 # Tested in testSync.
578 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1'])
579 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!')
580
581 # Without --verbose, gclient won't output the directories without
582 # modification.
583 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'],
584 [['running', join(self.root_dir, 'src')],
585 ['running', join(self.root_dir, 'src', 'other')]])
586 out = self.svnBlockCleanup(out)
587 self.checkString('other', out[0][1])
588 self.checkString(join('third_party', 'fpp'), out[0][2])
589 self.checkString(join('third_party', 'prout'), out[0][3])
590 self.checkString('hi', out[1][1])
591 self.assertEquals(4, len(out[0]))
592 self.assertEquals(2, len(out[1]))
593
594 # So verify it works with --verbose.
595 out = self.parseGclient(
596 ['status', '--deps', 'mac', '--verbose', '--jobs', '1'],
597 [['running', join(self.root_dir, 'src')],
598 ['running', join(self.root_dir, 'src', 'other')],
599 ['running', join(self.root_dir, 'src', 'third_party', 'fpp')],
600 ['running', join(self.root_dir, 'src', 'third_party', 'prout')]])
601 out = self.svnBlockCleanup(out)
602 self.checkString('other', out[0][5])
603 self.checkString(join('third_party', 'fpp'), out[0][7])
604 self.checkString(join('third_party', 'prout'), out[0][8])
605 self.checkString('hi', out[1][5])
606 self.assertEquals(9, len(out[0]))
607 self.assertEquals(7, len(out[1]))
608 self.assertEquals(6, len(out[2]))
609 self.assertEquals(6, len(out[3]))
610 self.assertEquals(4, len(out))
611
612 # Revert implies --force implies running hooks without looking at pattern
613 # matching.
614 # TODO(maruel): In general, gclient revert output is wrong. It should output
615 # the file list after some ___ running 'svn status'
616 results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1'])
617 out = self.splitBlock(results[0])
618 self.assertEquals(4, len(out))
619 self.checkString('', results[1])
620 self.assertEquals(0, results[2])
621 tree = self.mangle_svn_tree(
622 ('trunk/src@1', 'src'),
623 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
624 ('trunk/other@1', 'src/other'),
625 ('trunk/third_party/prout@2', 'src/third_party/prout'))
626 self.assertTree(tree)
627
628 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'],
629 [['running', join(self.root_dir, 'src')]])
630 out = self.svnBlockCleanup(out)
631 self.checkString('other', out[0][1])
632 self.checkString(join('third_party', 'fpp'), out[0][2])
633 self.checkString(join('third_party', 'prout'), out[0][3])
634 self.assertEquals(4, len(out[0]))
635
636 def testRunHooks(self):
637 if not self.enabled:
638 return
639 self.gclient(['config', self.svn_base + 'trunk/src/'])
640 self.gclient(['sync', '--deps', 'mac'])
641 out = self.parseGclient(['runhooks', '--deps', 'mac'],
642 ['running', 'running'])
643 self.checkString(1, len(out[0]))
644 self.checkString(1, len(out[1]))
645
646 def testRunHooksDepsOs(self):
647 if not self.enabled:
648 return
649 self.gclient(['config', self.svn_base + 'trunk/src/'])
650 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1'])
651 out = self.parseGclient(['runhooks', '--deps', 'mac'], [])
652 self.assertEquals([], out)
653
654 def testRevInfo(self):
655 if not self.enabled:
656 return
657 self.gclient(['config', self.svn_base + 'trunk/src/'])
658 self.gclient(['sync', '--deps', 'mac'])
659 results = self.gclient(['revinfo', '--deps', 'mac'])
660 out = ('src: %(base)s/src\n'
661 'src/file/other: File("%(base)s/other/DEPS")\n'
662 'src/other: %(base)s/other\n'
663 'src/third_party/foo: %(base)s/third_party/foo@1\n' %
664 { 'base': self.svn_base + 'trunk' })
665 self.check((out, '', 0), results)
666 results = self.gclient(['revinfo', '--deps', 'mac', '--actual'])
667 out = ('src: %(base)s/src@2\n'
668 'src/file/other: %(base)s/other/DEPS@2\n'
669 'src/other: %(base)s/other@2\n'
670 'src/third_party/foo: %(base)s/third_party/foo@1\n' %
671 { 'base': self.svn_base + 'trunk' })
672 self.check((out, '', 0), results)
673 results = self.gclient(['revinfo', '--deps', 'mac', '--snapshot'])
674 out = ('# Snapshot generated with gclient revinfo --snapshot\n'
675 'solutions = [\n'
676 ' { "name" : "src",\n'
677 ' "url" : "%(base)s/src",\n'
678 ' "deps_file" : "DEPS",\n'
679 ' "managed" : True,\n'
680 ' "custom_deps" : {\n'
681 ' "foo/bar": None,\n'
682 ' "invalid": None,\n'
683 ' "src/file/other": \'%(base)s/other/DEPS@2\',\n'
684 ' "src/other": \'%(base)s/other@2\',\n'
685 ' "src/third_party/foo": '
686 '\'%(base)s/third_party/foo@1\',\n'
687 ' },\n'
688 ' "safesync_url": "",\n'
689 ' },\n'
690 ']\n\n' %
691 { 'base': self.svn_base + 'trunk' })
692 self.check((out, '', 0), results)
693
694 def testRevInfoAltDeps(self):
695 if not self.enabled:
696 return
697 self.gclient(['config', self.svn_base + 'trunk/src/', '--deps-file',
698 'DEPS.alt'])
699 self.gclient(['sync'])
700 results = self.gclient(['revinfo', '--snapshot'])
701 out = ('# Snapshot generated with gclient revinfo --snapshot\n'
702 'solutions = [\n'
703 ' { "name" : "src",\n'
704 ' "url" : "%(base)s/src",\n'
705 ' "deps_file" : "DEPS.alt",\n'
706 ' "managed" : True,\n'
707 ' "custom_deps" : {\n'
708 ' "foo/bar": None,\n'
709 ' "invalid": None,\n'
710 ' "src/other2": \'%(base)s/other@2\',\n'
711 ' },\n'
712 ' "safesync_url": "",\n'
713 ' },\n'
714 ']\n\n' %
715 { 'base': self.svn_base + 'trunk' })
716 self.check((out, '', 0), results)
717
718
719 def testWrongDirectory(self):
720 # Check that we're not using a .gclient configuration which only talks
721 # about a subdirectory src when we're in a different subdirectory src-other.
722 if not self.enabled:
723 return
724 self.gclient(['config', self.svn_base + 'trunk/src/'])
725 self.gclient(['sync'])
726 other_src = join(self.root_dir, 'src-other')
727 os.mkdir(other_src)
728 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1)
729 self.check(res, self.gclient(['status'], other_src))
730
731 def testCorrectDirectory(self):
732 # Check that when we're in the subdirectory src, the .gclient configuration
733 # is used.
734 if not self.enabled:
735 return
736 self.gclient(['config', self.svn_base + 'trunk/src/'])
737 self.gclient(['sync'])
738 src = join(self.root_dir, 'src')
739 res = self.gclient(['status', '--jobs', '1'], src)
740 self.checkBlock(res[0], [('running', src)])
741
742 def testInitialCheckoutNotYetDone(self):
743 # Check that gclient can be executed when the initial checkout hasn't been
744 # done yet.
745 if not self.enabled:
746 return
747 self.gclient(['config', self.svn_base + 'trunk/src/'])
748 self.parseGclient(
749 ['sync', '--jobs', '1'],
750 ['running', 'running',
751 # This is due to the way svn update is called for a
752 # single file when File() is used in a DEPS file.
753 ('running', os.path.join(self.root_dir, 'src', 'file', 'other')),
754 'running', 'running', 'running', 'running'])
755
756 def testInitialCheckoutFailed(self):
757 # Check that gclient can be executed from an arbitrary sub directory if the
758 # initial checkout has failed.
759 if not self.enabled:
760 return
761 self.gclient(['config', self.svn_base + 'trunk/src/'])
762 self.gclient(['sync'])
763 # Cripple the checkout.
764 os.remove(join(self.root_dir, '.gclient_entries'))
765 src = join(self.root_dir, 'src')
766 res = self.gclient(['sync', '--jobs', '1'], src)
767 self.checkBlock(res[0],
768 ['running', 'running', 'running'])
769
770 def testUnversionedRepository(self):
771 # Check that gclient automatically deletes crippled SVN repositories.
772 if not self.enabled:
773 return
774 self.gclient(['config', self.svn_base + 'trunk/src/'])
775 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset']
776 self.assertEquals(0, self.gclient(cmd)[-1])
777 third_party = join(self.root_dir, 'src', 'third_party')
778 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'],
779 cwd=third_party)
780
781 # Cripple src/third_party/foo and make sure gclient still succeeds.
782 gclient_utils.rmtree(join(third_party, 'foo', '.svn'))
783 self.assertEquals(0, self.gclient(cmd)[-1])
784
785
786 class GClientSmokeSVNTransitive(GClientSmokeBase):
787 FAKE_REPOS_CLASS = FakeRepoTransitive
788
789 def setUp(self):
790 super(GClientSmokeSVNTransitive, self).setUp()
791 self.enabled = self.FAKE_REPOS.set_up_svn()
792
793 def testSyncTransitive(self):
794 if not self.enabled:
795 return
796
797 self.gclient(['config', self.svn_base + 'trunk/src/'])
798
799 def test_case(parent, timestamp, fixed, output):
800 # We check out revision 'parent' and expect the following:
801 # - src/ is checked out at r'parent'
802 # - src/same_repo is checked out at r'parent' (due to --transitive)
803 # - src/same_repo_fixed is checked out at r'fixed'
804 # - src/different_repo is checked out at r'timestamp'
805 # (due to --transitive)
806 # - src/different_repo_fixed is checked out at r'fixed'
807
808 revisions = self.FAKE_REPOS.svn_revs
809 self.parseGclient(
810 ['sync', '--transitive', '--revision', 'src@%d' % parent,
811 '--jobs', '1'], output)
812 self.assertTree({
813 'src/origin': revisions[parent]['trunk/src/origin'],
814 'src/DEPS': revisions[parent]['trunk/src/DEPS'],
815 'src/same_repo/origin': revisions[parent]['trunk/third_party/origin'],
816 'src/same_repo_fixed/origin':
817 revisions[fixed]['trunk/third_party/origin'],
818 'src/different_repo/origin':
819 revisions[timestamp]['trunk/third_party/origin'],
820 'src/different_repo_fixed/origin':
821 revisions[fixed]['trunk/third_party/origin'],
822 })
823
824 # Here are the test cases for checking out 'trunk/src' at r1, r2 and r3
825 # r1: Everything is normal
826 test_case(parent=1, timestamp=1, fixed=1,
827 output=['running', 'running', 'running', 'running', 'running'])
828 # r2: Svn will scan from r1 upwards until it finds a revision matching the
829 # given timestamp or it takes the next smallest one (which is r2 in this
830 # case).
831 test_case(parent=2, timestamp=2, fixed=1,
832 output=['running', 'running', 'running'])
833 # r3: Svn will scan from r1 upwards until it finds a revision matching the
834 # given timestamp or it takes the next smallest one. Since
835 # timestamp(r3) < timestamp(r2) svn will checkout r1.
836 # This happens often on http://googlecode.com but is unexpected to happen
837 # with svnserve (unless you manually change 'svn:date')
838 test_case(parent=3, timestamp=1, fixed=1,
839 output=['running', 'running', 'running'])
840
841
842 class GClientSmokeGIT(GClientSmokeBase): 301 class GClientSmokeGIT(GClientSmokeBase):
843 def setUp(self): 302 def setUp(self):
844 super(GClientSmokeGIT, self).setUp() 303 super(GClientSmokeGIT, self).setUp()
845 self.enabled = self.FAKE_REPOS.set_up_git() 304 self.enabled = self.FAKE_REPOS.set_up_git()
846 305
847 def testSync(self): 306 def testSync(self):
848 if not self.enabled: 307 if not self.enabled:
849 return 308 return
850 # TODO(maruel): safesync. 309 # TODO(maruel): safesync.
851 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) 310 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 672
1214 # Check that repo_2 is actually shallow and its log has only one entry. 673 # Check that repo_2 is actually shallow and its log has only one entry.
1215 rev_lists = subprocess2.check_output(['git', 'rev-list', 'HEAD'], 674 rev_lists = subprocess2.check_output(['git', 'rev-list', 'HEAD'],
1216 cwd=repo2_root) 675 cwd=repo2_root)
1217 self.assertEquals(repo_2_hash_new, rev_lists.strip('\r\n')) 676 self.assertEquals(repo_2_hash_new, rev_lists.strip('\r\n'))
1218 677
1219 # Check that we have actually checked out the right commit. 678 # Check that we have actually checked out the right commit.
1220 self.assertTrue(os.path.exists(join(repo2_root, 'last_file'))) 679 self.assertTrue(os.path.exists(join(repo2_root, 'last_file')))
1221 680
1222 681
1223 class GClientSmokeBoth(GClientSmokeBase):
1224 def setUp(self):
1225 super(GClientSmokeBoth, self).setUp()
1226 self.enabled = self.FAKE_REPOS.set_up_svn() and self.FAKE_REPOS.set_up_git()
1227
1228 def testMultiSolutions(self):
1229 if not self.enabled:
1230 return
1231 self.gclient(['config', '--spec',
1232 'solutions=['
1233 '{"name": "src",'
1234 ' "url": "' + self.svn_base + 'trunk/src/"},'
1235 '{"name": "src-git",'
1236 '"url": "' + self.git_base + 'repo_1"}]'])
1237 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'],
1238 ['running', 'running',
1239 # This is due to the way svn update is called for a single
1240 # file when File() is used in a DEPS file.
1241 ('running', self.root_dir + '/src/file/other'),
1242 'running', 'running', 'running', 'running',
1243 'running', 'running'])
1244 tree = self.mangle_git_tree(('repo_1@2', 'src-git'),
1245 ('repo_2@1', 'src/repo2'),
1246 ('repo_3@2', 'src/repo2/repo_renamed'))
1247 tree.update(self.mangle_svn_tree(
1248 ('trunk/src@2', 'src'),
1249 ('trunk/third_party/foo@1', 'src/third_party/foo'),
1250 ('trunk/other@2', 'src/other')))
1251 tree['src/file/other/DEPS'] = (
1252 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
1253 tree['src/git_hooked1'] = 'git_hooked1'
1254 tree['src/git_hooked2'] = 'git_hooked2'
1255 tree['src/svn_hooked1'] = 'svn_hooked1'
1256 self.assertTree(tree)
1257
1258 def testMultiSolutionsJobs(self):
1259 if not self.enabled:
1260 return
1261 self.gclient(['config', '--spec',
1262 'solutions=['
1263 '{"name": "src",'
1264 ' "url": "' + self.svn_base + 'trunk/src/"},'
1265 '{"name": "src-git",'
1266 '"url": "' + self.git_base + 'repo_1"}]'])
1267 # There is no guarantee that the ordering will be consistent.
1268 (stdout, stderr, returncode) = self.gclient(
1269 ['sync', '--deps', 'mac', '--jobs', '8'])
1270 stdout = self.untangle(stdout)
1271 self.checkString('', stderr)
1272 self.assertEquals(0, returncode)
1273 results = self.splitBlock(stdout)
1274 self.assertEquals(9, len(results))
1275 tree = self.mangle_git_tree(('repo_1@2', 'src-git'),
1276 ('repo_2@1', 'src/repo2'),
1277 ('repo_3@2', 'src/repo2/repo_renamed'))
1278 tree.update(self.mangle_svn_tree(
1279 ('trunk/src@2', 'src'),
1280 ('trunk/third_party/foo@1', 'src/third_party/foo'),
1281 ('trunk/other@2', 'src/other')))
1282 tree['src/file/other/DEPS'] = (
1283 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS'])
1284 tree['src/git_hooked1'] = 'git_hooked1'
1285 tree['src/git_hooked2'] = 'git_hooked2'
1286 tree['src/svn_hooked1'] = 'svn_hooked1'
1287 self.assertTree(tree)
1288
1289 def testMultiSolutionsMultiRev(self):
1290 if not self.enabled:
1291 return
1292 self.gclient(['config', '--spec',
1293 'solutions=['
1294 '{"name": "src",'
1295 ' "url": "' + self.svn_base + 'trunk/src/"},'
1296 '{"name": "src-git",'
1297 '"url": "' + self.git_base + 'repo_1"}]'])
1298 self.parseGclient(
1299 ['sync', '--deps', 'mac', '--jobs', '1', '--revision', '1',
1300 '-r', 'src-git@' + self.githash('repo_1', 1)],
1301 ['running', 'running', 'running', 'running'],
1302 expected_stderr=
1303 'You must specify the full solution name like --revision src@1\n'
1304 'when you have multiple solutions setup in your .gclient file.\n'
1305 'Other solutions present are: src-git.\n')
1306 tree = self.mangle_git_tree(('repo_1@1', 'src-git'),
1307 ('repo_2@2', 'src/repo2'),
1308 ('repo_3@1', 'src/repo2/repo3'),
1309 ('repo_4@2', 'src/repo4'))
1310 tree.update(self.mangle_svn_tree(
1311 ('trunk/src@1', 'src'),
1312 ('trunk/third_party/foo@2', 'src/third_party/fpp'),
1313 ('trunk/other@1', 'src/other'),
1314 ('trunk/third_party/foo@2', 'src/third_party/prout')))
1315 self.assertTree(tree)
1316
1317 def testRevInfo(self):
1318 if not self.enabled:
1319 return
1320 self.gclient(['config', '--spec',
1321 'solutions=['
1322 '{"name": "src",'
1323 ' "url": "' + self.svn_base + 'trunk/src/"},'
1324 '{"name": "src-git",'
1325 '"url": "' + self.git_base + 'repo_1"}]'])
1326 self.gclient(['sync', '--deps', 'mac'])
1327 results = self.gclient(['revinfo', '--deps', 'mac'])
1328 out = ('src: %(svn_base)s/src/\n'
1329 'src-git: %(git_base)srepo_1\n'
1330 'src/file/other: File("%(svn_base)s/other/DEPS")\n'
1331 'src/other: %(svn_base)s/other\n'
1332 'src/repo2: %(git_base)srepo_2@%(hash2)s\n'
1333 'src/repo2/repo_renamed: %(git_base)srepo_3\n'
1334 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % {
1335 'svn_base': self.svn_base + 'trunk',
1336 'git_base': self.git_base,
1337 'hash2': self.githash('repo_2', 1)[:7],
1338 }
1339 self.check((out, '', 0), results)
1340 results = self.gclient(['revinfo', '--deps', 'mac', '--actual'])
1341 out = ('src: %(svn_base)s/src/@2\n'
1342 'src-git: %(git_base)srepo_1@%(hash1)s\n'
1343 'src/file/other: %(svn_base)s/other/DEPS@2\n'
1344 'src/other: %(svn_base)s/other@2\n'
1345 'src/repo2: %(git_base)srepo_2@%(hash2)s\n'
1346 'src/repo2/repo_renamed: %(git_base)srepo_3@%(hash3)s\n'
1347 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % {
1348 'svn_base': self.svn_base + 'trunk',
1349 'git_base': self.git_base,
1350 'hash1': self.githash('repo_1', 2),
1351 'hash2': self.githash('repo_2', 1),
1352 'hash3': self.githash('repo_3', 2),
1353 }
1354 self.check((out, '', 0), results)
1355
1356 def testRecurse(self):
1357 if not self.enabled:
1358 return
1359 self.gclient(['config', '--spec',
1360 'solutions=['
1361 '{"name": "src",'
1362 ' "url": "' + self.svn_base + 'trunk/src/"},'
1363 '{"name": "src-git",'
1364 '"url": "' + self.git_base + 'repo_1"}]'])
1365 self.gclient(['sync', '--deps', 'mac'])
1366 results = self.gclient(['recurse', '-j1', 'sh', '-c',
1367 'echo $GCLIENT_SCM,$GCLIENT_URL,`pwd`'])
1368
1369 entries = [tuple(line.split(','))
1370 for line in results[0].strip().split('\n')]
1371 logging.debug(entries)
1372
1373 bases = {'svn': self.svn_base, 'git': self.git_base}
1374 expected_source = [
1375 ('svn', 'trunk/src/', 'src'),
1376 ('git', 'repo_1', 'src-git'),
1377 ('svn', 'trunk/other', 'src/other'),
1378 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'),
1379 ('git', 'repo_3', 'src/repo2/repo_renamed'),
1380 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'),
1381 ]
1382 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path))
1383 for (scm, url, path) in expected_source]
1384
1385 self.assertEquals(sorted(entries), sorted(expected))
1386
1387
1388 class SkiaDEPSTransitionSmokeTest(GClientSmokeBase): 682 class SkiaDEPSTransitionSmokeTest(GClientSmokeBase):
1389 """Simulate the behavior of bisect bots as they transition across the Skia 683 """Simulate the behavior of bisect bots as they transition across the Skia
1390 DEPS change.""" 684 DEPS change."""
1391 685
1392 FAKE_REPOS_CLASS = FakeRepoSkiaDEPS 686 FAKE_REPOS_CLASS = fake_repos.FakeRepoSkiaDEPS
1393 687
1394 def setUp(self): 688 def setUp(self):
1395 super(SkiaDEPSTransitionSmokeTest, self).setUp() 689 super(SkiaDEPSTransitionSmokeTest, self).setUp()
1396 self.enabled = self.FAKE_REPOS.set_up_git() and self.FAKE_REPOS.set_up_svn() 690 self.enabled = self.FAKE_REPOS.set_up_git()
1397
1398 def testSkiaDEPSChangeSVN(self):
1399 if not self.enabled:
1400 return
1401
1402 # Create an initial checkout:
1403 # - Single checkout at the root.
1404 # - Multiple checkouts in a shared subdirectory.
1405 self.gclient(['config', '--spec',
1406 'solutions=['
1407 '{"name": "src",'
1408 ' "url": "' + self.svn_base + 'trunk/src/",'
1409 '}]'])
1410
1411 checkout_path = os.path.join(self.root_dir, 'src')
1412 skia = os.path.join(checkout_path, 'third_party', 'skia')
1413 skia_gyp = os.path.join(skia, 'gyp')
1414 skia_include = os.path.join(skia, 'include')
1415 skia_src = os.path.join(skia, 'src')
1416
1417 gyp_svn_url = self.svn_base + 'skia/gyp'
1418 include_svn_url = self.svn_base + 'skia/include'
1419 src_svn_url = self.svn_base + 'skia/src'
1420 skia_git_url = self.git_base + 'repo_1'
1421
1422 # Initial sync. Verify that we get the expected checkout.
1423 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2'])
1424 self.assertEqual(res[2], 0, 'Initial sync failed.')
1425 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'],
1426 gyp_svn_url)
1427 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'],
1428 include_svn_url)
1429 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'],
1430 src_svn_url)
1431
1432 # Verify that the sync succeeds. Verify that we have the expected merged
1433 # checkout.
1434 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3'])
1435 self.assertEqual(res[2], 0, 'DEPS change sync failed.')
1436 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1437 skia), skia_git_url)
1438
1439 # Sync again. Verify that we still have the expected merged checkout.
1440 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3'])
1441 self.assertEqual(res[2], 0, 'Subsequent sync failed.')
1442 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1443 skia), skia_git_url)
1444
1445 # Sync back to the original DEPS. Verify that we get the original structure.
1446 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2'])
1447 self.assertEqual(res[2], 0, 'Reverse sync failed.')
1448 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'],
1449 gyp_svn_url)
1450 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'],
1451 include_svn_url)
1452 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'],
1453 src_svn_url)
1454
1455 # Sync again. Verify that we still have the original structure.
1456 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2'])
1457 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.')
1458 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'],
1459 gyp_svn_url)
1460 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'],
1461 include_svn_url)
1462 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'],
1463 src_svn_url)
1464 691
1465 def testSkiaDEPSChangeGit(self): 692 def testSkiaDEPSChangeGit(self):
1466 if not self.enabled: 693 if not self.enabled:
1467 return 694 return
1468 695
1469 # Create an initial checkout: 696 # Create an initial checkout:
1470 # - Single checkout at the root. 697 # - Single checkout at the root.
1471 # - Multiple checkouts in a shared subdirectory. 698 # - Multiple checkouts in a shared subdirectory.
1472 self.gclient(['config', '--spec', 699 self.gclient(['config', '--spec',
1473 'solutions=[' 700 'solutions=['
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], 762 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1536 skia_include), include_git_url) 763 skia_include), include_git_url)
1537 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], 764 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1538 skia_src), src_git_url) 765 skia_src), src_git_url)
1539 766
1540 767
1541 class BlinkDEPSTransitionSmokeTest(GClientSmokeBase): 768 class BlinkDEPSTransitionSmokeTest(GClientSmokeBase):
1542 """Simulate the behavior of bisect bots as they transition across the Blink 769 """Simulate the behavior of bisect bots as they transition across the Blink
1543 DEPS change.""" 770 DEPS change."""
1544 771
1545 FAKE_REPOS_CLASS = FakeRepoBlinkDEPS 772 FAKE_REPOS_CLASS = fake_repos.FakeRepoBlinkDEPS
1546 773
1547 def setUp(self): 774 def setUp(self):
1548 super(BlinkDEPSTransitionSmokeTest, self).setUp() 775 super(BlinkDEPSTransitionSmokeTest, self).setUp()
1549 self.enabled = self.FAKE_REPOS.set_up_git() 776 self.enabled = self.FAKE_REPOS.set_up_git()
1550 self.checkout_path = os.path.join(self.root_dir, 'src') 777 self.checkout_path = os.path.join(self.root_dir, 'src')
1551 self.blink = os.path.join(self.checkout_path, 'third_party', 'WebKit') 778 self.blink = os.path.join(self.checkout_path, 'third_party', 'WebKit')
1552 self.blink_git_url = self.FAKE_REPOS.git_base + 'repo_2' 779 self.blink_git_url = self.FAKE_REPOS.git_base + 'repo_2'
1553 self.pre_merge_sha = self.githash('repo_1', 1) 780 self.pre_merge_sha = self.githash('repo_1', 1)
1554 self.post_merge_sha = self.githash('repo_1', 2) 781 self.post_merge_sha = self.githash('repo_1', 2)
1555 782
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 self.gclient(['sync', '--revision', 'src@%s' % self.post_merge_sha]) 893 self.gclient(['sync', '--revision', 'src@%s' % self.post_merge_sha])
1667 self.CheckStatusPostMergePoint() 894 self.CheckStatusPostMergePoint()
1668 895
1669 # Go backwards and check that we still have the foo branch. 896 # Go backwards and check that we still have the foo branch.
1670 self.gclient(['sync', '--revision', 'src@%s' % self.pre_merge_sha]) 897 self.gclient(['sync', '--revision', 'src@%s' % self.pre_merge_sha])
1671 self.CheckStatusPreMergePoint() 898 self.CheckStatusPreMergePoint()
1672 subprocess2.check_call( 899 subprocess2.check_call(
1673 ['git', 'show-ref', '-q', '--verify', 'refs/heads/foo'], cwd=self.blink) 900 ['git', 'show-ref', '-q', '--verify', 'refs/heads/foo'], cwd=self.blink)
1674 901
1675 902
1676 class GClientSmokeFromCheckout(GClientSmokeBase):
1677 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1678 def setUp(self):
1679 super(GClientSmokeFromCheckout, self).setUp()
1680 self.enabled = self.FAKE_REPOS.set_up_svn()
1681 os.rmdir(self.root_dir)
1682 if self.enabled:
1683 usr, pwd = self.FAKE_REPOS.USERS[0]
1684 subprocess2.check_call(
1685 ['svn', 'checkout', self.svn_base + '/trunk/webkit',
1686 self.root_dir, '-q',
1687 '--non-interactive', '--no-auth-cache',
1688 '--username', usr, '--password', pwd])
1689
1690 def testSync(self):
1691 if not self.enabled:
1692 return
1693 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'],
1694 ['running', 'running'])
1695 tree = self.mangle_svn_tree(
1696 ('trunk/webkit@2', ''),
1697 ('trunk/third_party/foo@1', 'foo/bar'))
1698 self.assertTree(tree)
1699
1700 def testRevertAndStatus(self):
1701 if not self.enabled:
1702 return
1703 self.gclient(['sync'])
1704
1705 # TODO(maruel): This is incorrect.
1706 out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], [])
1707
1708 # Revert implies --force implies running hooks without looking at pattern
1709 # matching.
1710 results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1'])
1711 out = self.splitBlock(results[0])
1712 self.assertEquals(2, len(out))
1713 # This value varies depending on the version of svn being run.
1714 # New vesions (the one in Trust) print "Updating '.':" and "At revision 1.".
1715 # Older versions (the one in Precise) print just "At revision 1.".
1716 #self.assertEquals(3, len(out[0]))
1717 self.assertEquals(2, len(out[1]))
1718 self.checkString('foo', out[1][1])
1719 self.checkString('', results[1])
1720 self.assertEquals(0, results[2])
1721 tree = self.mangle_svn_tree(
1722 ('trunk/webkit@2', ''),
1723 ('trunk/third_party/foo@1', 'foo/bar'))
1724 self.assertTree(tree)
1725
1726 # TODO(maruel): This is incorrect.
1727 out = self.parseGclient(['status', '--deps', 'mac'], [])
1728
1729 def testRunHooks(self):
1730 if not self.enabled:
1731 return
1732 # Hooks aren't really tested for now since there is no hook defined.
1733 self.gclient(['sync', '--deps', 'mac'])
1734 out = self.parseGclient(['runhooks', '--deps', 'mac'], ['running'])
1735 self.assertEquals(1, len(out))
1736 self.assertEquals(2, len(out[0]))
1737 self.assertEquals(3, len(out[0][0]))
1738 self.checkString('foo', out[0][1])
1739 tree = self.mangle_svn_tree(
1740 ('trunk/webkit@2', ''),
1741 ('trunk/third_party/foo@1', 'foo/bar'))
1742 self.assertTree(tree)
1743
1744 def testRevInfo(self):
1745 if not self.enabled:
1746 return
1747 self.gclient(['sync', '--deps', 'mac'])
1748 results = self.gclient(['revinfo', '--deps', 'mac'])
1749 expected = (
1750 './: None\nfoo/bar: %strunk/third_party/foo@1\n' % self.svn_base,
1751 '', 0)
1752 self.check(expected, results)
1753 # TODO(maruel): To be added after the refactor.
1754 #results = self.gclient(['revinfo', '--snapshot'])
1755 #expected = (
1756 # './: None\nfoo/bar: %strunk/third_party/foo@1\n' % self.svn_base,
1757 # '', 0)
1758 #self.check(expected, results)
1759
1760 def testRest(self):
1761 if not self.enabled:
1762 return
1763 self.gclient(['sync'])
1764 # TODO(maruel): This is incorrect, it should run on ./ too.
1765 self.parseGclient(
1766 ['cleanup', '--deps', 'mac', '--verbose', '--jobs', '1'],
1767 [('running', join(self.root_dir, 'foo', 'bar'))])
1768 self.parseGclient(
1769 ['diff', '--deps', 'mac', '--verbose', '--jobs', '1'],
1770 [('running', join(self.root_dir, 'foo', 'bar'))])
1771
1772
1773 if __name__ == '__main__': 903 if __name__ == '__main__':
1774 if '-v' in sys.argv: 904 if '-v' in sys.argv:
1775 logging.basicConfig(level=logging.DEBUG) 905 logging.basicConfig(level=logging.DEBUG)
1776 906
1777 if '-c' in sys.argv: 907 if '-c' in sys.argv:
1778 COVERAGE = True 908 COVERAGE = True
1779 sys.argv.remove('-c') 909 sys.argv.remove('-c')
1780 if os.path.exists('.coverage'): 910 if os.path.exists('.coverage'):
1781 os.remove('.coverage') 911 os.remove('.coverage')
1782 os.environ['COVERAGE_FILE'] = os.path.join( 912 os.environ['COVERAGE_FILE'] = os.path.join(
1783 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 913 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1784 '.coverage') 914 '.coverage')
1785 unittest.main() 915 unittest.main()
OLDNEW
« no previous file with comments | « tests/gclient_scm_test.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698