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

Side by Side Diff: tests/gclient_smoketest.py

Issue 183283003: Another attempt: gclient: delete mismatching checkouts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: More minimal approach Created 6 years, 9 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.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if not match: 102 if not match:
103 match = re.match(r'^_____ (.*) is missing, synching instead$', line) 103 match = re.match(r'^_____ (.*) is missing, synching instead$', line)
104 if match: 104 if match:
105 # Blah, it's when a dependency is deleted, we should probably not 105 # Blah, it's when a dependency is deleted, we should probably not
106 # output this message. 106 # output this message.
107 results.append([line]) 107 results.append([line])
108 elif ( 108 elif (
109 not re.match( 109 not re.match(
110 r'_____ [^ ]+ : Attempting rebase onto [0-9a-f]+...', 110 r'_____ [^ ]+ : Attempting rebase onto [0-9a-f]+...',
111 line) and 111 line) and
112 not re.match(r'_____ [^ ]+ at [^ ]+', line)): 112 not re.match(r'_____ [^ ]+ at [^ ]+', line) and not
113 # The two regexp above are a bit too broad, they are necessary only 113 re.match(
114 # for git checkouts. 114 r'_____ (.*) looks like a git-svn checkout. Skipping.',
115 line)):
116 # The regexp above are a bit too broad.
115 self.fail(line) 117 self.fail(line)
116 else: 118 else:
117 results.append([[match.group(1), match.group(2), match.group(3)]]) 119 results.append([[match.group(1), match.group(2), match.group(3)]])
118 else: 120 else:
119 if not results: 121 if not results:
120 # TODO(maruel): gclient's git stdout is inconsistent. 122 # TODO(maruel): gclient's git stdout is inconsistent.
121 # This should fail the test instead!! 123 # This should fail the test instead!!
122 pass 124 pass
123 else: 125 else:
124 results[-1].append(line) 126 results[-1].append(line)
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 return 771 return
770 self.gclient(['config', self.svn_base + 'trunk/src/']) 772 self.gclient(['config', self.svn_base + 'trunk/src/'])
771 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] 773 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset']
772 self.assertEquals(0, self.gclient(cmd)[-1]) 774 self.assertEquals(0, self.gclient(cmd)[-1])
773 third_party = join(self.root_dir, 'src', 'third_party') 775 third_party = join(self.root_dir, 'src', 'third_party')
774 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], 776 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'],
775 cwd=third_party) 777 cwd=third_party)
776 778
777 # Cripple src/third_party/foo and make sure gclient still succeeds. 779 # Cripple src/third_party/foo and make sure gclient still succeeds.
778 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) 780 gclient_utils.rmtree(join(third_party, 'foo', '.svn'))
779 self.assertEquals(0, self.gclient(cmd)[-1]) 781 self.assertEquals(0, self.gclient(cmd + ['--force'])[-1])
782
783 def testSkipGitSvn(self):
borenet 2014/02/27 22:07:36 This test probably isn't needed.
784 # Check that gclient skips git-svn checkouts.
785 if not self.enabled:
786 return
787
788 # Create the .gclient file.
789 svn_url = self.svn_base + 'trunk/src'
790 self.gclient(['config', svn_url], cwd=self.root_dir)
791
792 # Create a git-svn checkout.
793 # Use check_output to hide the output from the subprocess.
794 subprocess2.check_output(['git', 'svn', 'clone', svn_url],
795 cwd=self.root_dir)
796
797 # Ensure that gclient skips the git-svn checkout.
798 stdout, stderr, rc = self.gclient(['sync', '--jobs', '1'])
799 self.assertEquals(rc, 0)
800 self.assertFalse(stderr)
801 self.assertTrue('_____ src looks like a git-svn checkout. Skipping.'
802 in stdout)
803 self.checkBlock(stdout, [
804 ['running', self.root_dir],
805 ['running', os.path.join(self.root_dir, 'src', 'file', 'other')],
806 ['running', self.root_dir],
807 ['running', self.root_dir],
808 ['running', self.root_dir],
809 ['running', self.root_dir],
810 ['running', self.root_dir],
811 ])
812
813 # But, we still need the DEPS to be checked out...
814 foo_dir = os.path.join(self.root_dir, 'src', 'third_party', 'foo')
815 foo_rev = subprocess2.check_output(['svnversion', foo_dir]).strip()
816 self.assertEquals(foo_rev, '1')
817
818 other_dir = os.path.join(self.root_dir, 'src', 'other')
819 other_rev = subprocess2.check_output(['svnversion', other_dir]).strip()
820 self.assertEquals(other_rev, '2')
821
822 # Verify that the DEPS are NOT skipped on a second update.
823 stdout, stderr, rc = self.gclient(['sync', '--jobs', '1'])
824 self.assertFalse(stderr)
825 self.assertTrue('_____ src looks like a git-svn checkout. Skipping.'
826 in stdout)
827 self.assertFalse(
828 '_____ src/other looks like a git-svn checkout. Skipping.' in stdout,
829 'Non git-svn checkout is incorrectly skipped.')
830 self.assertFalse(
831 '_____ src/third_party/foo looks like a git-svn checkout. Skipping.'
832 in stdout,
833 'Non git-svn checkout is incorrectly skipped.')
780 834
781 835
782 class GClientSmokeSVNTransitive(GClientSmokeBase): 836 class GClientSmokeSVNTransitive(GClientSmokeBase):
783 FAKE_REPOS_CLASS = FakeRepoTransitive 837 FAKE_REPOS_CLASS = FakeRepoTransitive
784 838
785 def setUp(self): 839 def setUp(self):
786 super(GClientSmokeSVNTransitive, self).setUp() 840 super(GClientSmokeSVNTransitive, self).setUp()
787 self.enabled = self.FAKE_REPOS.set_up_svn() 841 self.enabled = self.FAKE_REPOS.set_up_svn()
788 842
789 def testSyncTransitive(self): 843 def testSyncTransitive(self):
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 ('svn', 'trunk/other', 'src/other'), 1443 ('svn', 'trunk/other', 'src/other'),
1390 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), 1444 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'),
1391 ('git', 'repo_3', 'src/repo2/repo_renamed'), 1445 ('git', 'repo_3', 'src/repo2/repo_renamed'),
1392 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), 1446 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'),
1393 ] 1447 ]
1394 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) 1448 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path))
1395 for (scm, url, path) in expected_source] 1449 for (scm, url, path) in expected_source]
1396 1450
1397 self.assertEquals(sorted(entries), sorted(expected)) 1451 self.assertEquals(sorted(entries), sorted(expected))
1398 1452
1453 def testDeleteConflictingCheckout(self):
borenet 2014/02/27 22:07:36 This test probably isn't needed. It should maybe
1454 if not self.enabled:
1455 return
1456
1457 # Create an initial svn checkout.
1458 self.gclient(['config', '--spec',
1459 'solutions=['
1460 '{"name": "src",'
1461 ' "url": "' + self.svn_base + 'trunk/src"},'
1462 ']'
1463 ])
1464 results = self.gclient(['sync', '--deps', 'mac'])
1465 self.assertEqual(results[2], 0, 'Sync failed!')
1466
1467 # Verify that we have the expected svn checkout.
1468 results = self.gclient(['revinfo', '--deps', 'mac'])
1469 actual = results[0].splitlines()
1470 expected = [
1471 'src: %strunk/src' % self.svn_base,
1472 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1473 'src/other: %strunk/other' % self.svn_base,
1474 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1475 ]
1476 self.assertEquals(actual, expected)
1477
1478 # Change the desired checkout to git.
1479 self.gclient(['config', '--spec',
1480 'solutions=['
1481 '{"name": "src",'
1482 ' "url": "' + self.git_base + 'repo_1"},'
1483 ']'
1484 ])
1485
1486 # Verify that the sync succeeds with --force.
1487 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1488 self.assertEqual(results[2], 0, 'Sync failed!')
1489
1490 # Verify that we got the desired git checkout.
1491 results = self.gclient(['revinfo', '--deps', 'mac'])
1492 actual = results[0].splitlines()
1493 expected = [
1494 'src: %srepo_1' % self.git_base,
1495 'src/repo2: %srepo_2@%s' % (self.git_base,
1496 self.githash('repo_2', 1)[:7]),
1497 'src/repo2/repo_renamed: %srepo_3' % self.git_base,
1498 ]
1499 self.assertEquals(actual, expected)
1500
1501 # Change the desired checkout back to svn.
1502 self.gclient(['config', '--spec',
1503 'solutions=['
1504 '{"name": "src",'
1505 ' "url": "' + self.svn_base + 'trunk/src"},'
1506 ']'
1507 ])
1508
1509 # Verify that the sync succeeds.
1510 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1511 self.assertEqual(results[2], 0, 'Sync failed!')
1512
1513 # Verify that we have the expected svn checkout.
1514 results = self.gclient(['revinfo', '--deps', 'mac'])
1515 actual = results[0].splitlines()
1516 expected = [
1517 'src: %strunk/src' % self.svn_base,
1518 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1519 'src/other: %strunk/other' % self.svn_base,
1520 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1521 ]
1522 self.assertEquals(actual, expected)
1523
1399 1524
1400 class GClientSmokeFromCheckout(GClientSmokeBase): 1525 class GClientSmokeFromCheckout(GClientSmokeBase):
1401 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. 1526 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1402 def setUp(self): 1527 def setUp(self):
1403 super(GClientSmokeFromCheckout, self).setUp() 1528 super(GClientSmokeFromCheckout, self).setUp()
1404 self.enabled = self.FAKE_REPOS.set_up_svn() 1529 self.enabled = self.FAKE_REPOS.set_up_svn()
1405 os.rmdir(self.root_dir) 1530 os.rmdir(self.root_dir)
1406 if self.enabled: 1531 if self.enabled:
1407 usr, pwd = self.FAKE_REPOS.USERS[0] 1532 usr, pwd = self.FAKE_REPOS.USERS[0]
1408 subprocess2.check_call( 1533 subprocess2.check_call(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 1622
1498 if '-c' in sys.argv: 1623 if '-c' in sys.argv:
1499 COVERAGE = True 1624 COVERAGE = True
1500 sys.argv.remove('-c') 1625 sys.argv.remove('-c')
1501 if os.path.exists('.coverage'): 1626 if os.path.exists('.coverage'):
1502 os.remove('.coverage') 1627 os.remove('.coverage')
1503 os.environ['COVERAGE_FILE'] = os.path.join( 1628 os.environ['COVERAGE_FILE'] = os.path.join(
1504 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1629 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1505 '.coverage') 1630 '.coverage')
1506 unittest.main() 1631 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