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 164053003: Re-re-land gclient deletion of mismatching checkouts again (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Another attempt of gclient: delete mismatching checkouts 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/gclient_utils_test.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):
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 1109
1056 # Pre-DEPS hooks don't run with runhooks. 1110 # Pre-DEPS hooks don't run with runhooks.
1057 self.gclient(['runhooks', '--deps', 'mac']) 1111 self.gclient(['runhooks', '--deps', 'mac'])
1058 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1112 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1059 ('repo_1@2', 'src/repo1'), 1113 ('repo_1@2', 'src/repo1'),
1060 ('repo_2@1', 'src/repo2') 1114 ('repo_2@1', 'src/repo2')
1061 ) 1115 )
1062 self.assertTree(tree) 1116 self.assertTree(tree)
1063 1117
1064 # Pre-DEPS hooks run when syncing with --nohooks. 1118 # Pre-DEPS hooks run when syncing with --nohooks.
1065 self.gclient(['sync', '--deps', 'mac', '--nohooks', 1119 self.gclient(['sync', '--deps', 'mac', '--nohooks', '--force',
1066 '--revision', 'src@' + self.githash('repo_5', 2)]) 1120 '--revision', 'src@' + self.githash('repo_5', 2)])
1067 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1121 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1068 ('repo_1@2', 'src/repo1'), 1122 ('repo_1@2', 'src/repo1'),
1069 ('repo_2@1', 'src/repo2') 1123 ('repo_2@1', 'src/repo2')
1070 ) 1124 )
1071 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' 1125 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked'
1072 self.assertTree(tree) 1126 self.assertTree(tree)
1073 1127
1074 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) 1128 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked'))
1075 1129
1076 # Pre-DEPS hooks don't run with --noprehooks 1130 # Pre-DEPS hooks don't run with --noprehooks
1077 self.gclient(['sync', '--deps', 'mac', '--noprehooks', 1131 self.gclient(['sync', '--deps', 'mac', '--noprehooks', '--force',
1078 '--revision', 'src@' + self.githash('repo_5', 2)]) 1132 '--revision', 'src@' + self.githash('repo_5', 2)])
1079 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1133 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1080 ('repo_1@2', 'src/repo1'), 1134 ('repo_1@2', 'src/repo1'),
1081 ('repo_2@1', 'src/repo2') 1135 ('repo_2@1', 'src/repo2')
1082 ) 1136 )
1083 self.assertTree(tree) 1137 self.assertTree(tree)
1084 1138
1085 def testPreDepsHooksError(self): 1139 def testPreDepsHooksError(self):
1086 if not self.enabled: 1140 if not self.enabled:
1087 return 1141 return
(...skipping 301 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 if gclient_utils.enable_deletion_of_conflicting_checkouts():
1454 def testDeleteConflictingCheckout(self):
1455 if not self.enabled:
1456 return
1457
1458 # Create an initial svn checkout.
1459 self.gclient(['config', '--spec',
1460 'solutions=['
1461 '{"name": "src",'
1462 ' "url": "' + self.svn_base + 'trunk/src"},'
1463 ']'
1464 ])
1465 results = self.gclient(['sync', '--deps', 'mac'])
1466 self.assertEqual(results[2], 0, 'Sync failed!')
1467
1468 # Verify that we have the expected svn checkout.
1469 results = self.gclient(['revinfo', '--deps', 'mac'])
1470 actual = results[0].splitlines()
1471 expected = [
1472 'src: %strunk/src' % self.svn_base,
1473 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1474 'src/other: %strunk/other' % self.svn_base,
1475 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1476 ]
1477 self.assertEquals(actual, expected)
1478
1479 # Change the desired checkout to git.
1480 self.gclient(['config', '--spec',
1481 'solutions=['
1482 '{"name": "src",'
1483 ' "url": "' + self.git_base + 'repo_1"},'
1484 ']'
1485 ])
1486
1487 # Verify that the sync succeeds with --force.
1488 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1489 self.assertEqual(results[2], 0, 'Sync failed!')
1490
1491 # Verify that we got the desired git checkout.
1492 results = self.gclient(['revinfo', '--deps', 'mac'])
1493 actual = results[0].splitlines()
1494 expected = [
1495 'src: %srepo_1' % self.git_base,
1496 'src/repo2: %srepo_2@%s' % (self.git_base,
1497 self.githash('repo_2', 1)[:7]),
1498 'src/repo2/repo_renamed: %srepo_3' % self.git_base,
1499 ]
1500 self.assertEquals(actual, expected)
1501
1502 # Change the desired checkout back to svn.
1503 self.gclient(['config', '--spec',
1504 'solutions=['
1505 '{"name": "src",'
1506 ' "url": "' + self.svn_base + 'trunk/src"},'
1507 ']'
1508 ])
1509
1510 # Verify that the sync succeeds.
1511 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1512 self.assertEqual(results[2], 0, 'Sync failed!')
1513
1514 # Verify that we have the expected svn checkout.
1515 results = self.gclient(['revinfo', '--deps', 'mac'])
1516 actual = results[0].splitlines()
1517 expected = [
1518 'src: %strunk/src' % self.svn_base,
1519 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1520 'src/other: %strunk/other' % self.svn_base,
1521 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1522 ]
1523 self.assertEquals(actual, expected)
1524
1399 1525
1400 class GClientSmokeFromCheckout(GClientSmokeBase): 1526 class GClientSmokeFromCheckout(GClientSmokeBase):
1401 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. 1527 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1402 def setUp(self): 1528 def setUp(self):
1403 super(GClientSmokeFromCheckout, self).setUp() 1529 super(GClientSmokeFromCheckout, self).setUp()
1404 self.enabled = self.FAKE_REPOS.set_up_svn() 1530 self.enabled = self.FAKE_REPOS.set_up_svn()
1405 os.rmdir(self.root_dir) 1531 os.rmdir(self.root_dir)
1406 if self.enabled: 1532 if self.enabled:
1407 usr, pwd = self.FAKE_REPOS.USERS[0] 1533 usr, pwd = self.FAKE_REPOS.USERS[0]
1408 subprocess2.check_call( 1534 subprocess2.check_call(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 1623
1498 if '-c' in sys.argv: 1624 if '-c' in sys.argv:
1499 COVERAGE = True 1625 COVERAGE = True
1500 sys.argv.remove('-c') 1626 sys.argv.remove('-c')
1501 if os.path.exists('.coverage'): 1627 if os.path.exists('.coverage'):
1502 os.remove('.coverage') 1628 os.remove('.coverage')
1503 os.environ['COVERAGE_FILE'] = os.path.join( 1629 os.environ['COVERAGE_FILE'] = os.path.join(
1504 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1630 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1505 '.coverage') 1631 '.coverage')
1506 unittest.main() 1632 unittest.main()
OLDNEW
« no previous file with comments | « tests/gclient_scm_test.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698