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

Side by Side Diff: tests/gclient_smoketest.py

Issue 133073015: Re-reland r245404 ("If the destination directory doesn't contain the desired repo, delete it") (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Clean up check_output call, print hostname on bots 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 | « 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 socket
16 import subprocess 17 import subprocess
17 import sys 18 import sys
18 import unittest 19 import unittest
19 20
20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 21 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21 sys.path.insert(0, ROOT_DIR) 22 sys.path.insert(0, ROOT_DIR)
22 23
23 from testing_support.fake_repos import join, write 24 from testing_support.fake_repos import join, write
24 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive 25 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive
25 26
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if not match: 103 if not match:
103 match = re.match(r'^_____ (.*) is missing, synching instead$', line) 104 match = re.match(r'^_____ (.*) is missing, synching instead$', line)
104 if match: 105 if match:
105 # Blah, it's when a dependency is deleted, we should probably not 106 # Blah, it's when a dependency is deleted, we should probably not
106 # output this message. 107 # output this message.
107 results.append([line]) 108 results.append([line])
108 elif ( 109 elif (
109 not re.match( 110 not re.match(
110 r'_____ [^ ]+ : Attempting rebase onto [0-9a-f]+...', 111 r'_____ [^ ]+ : Attempting rebase onto [0-9a-f]+...',
111 line) and 112 line) and
112 not re.match(r'_____ [^ ]+ at [^ ]+', line)): 113 not re.match(r'_____ [^ ]+ at [^ ]+', line) and not
113 # The two regexp above are a bit too broad, they are necessary only 114 re.match(r'________ (.*) looks like git-svn; skipping.', line)):
114 # for git checkouts. 115 # The regexp above are a bit too broad.
115 self.fail(line) 116 self.fail(line)
116 else: 117 else:
117 results.append([[match.group(1), match.group(2), match.group(3)]]) 118 results.append([[match.group(1), match.group(2), match.group(3)]])
118 else: 119 else:
119 if not results: 120 if not results:
120 # TODO(maruel): gclient's git stdout is inconsistent. 121 # TODO(maruel): gclient's git stdout is inconsistent.
121 # This should fail the test instead!! 122 # This should fail the test instead!!
122 pass 123 pass
123 else: 124 else:
124 results[-1].append(line) 125 results[-1].append(line)
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 return 770 return
770 self.gclient(['config', self.svn_base + 'trunk/src/']) 771 self.gclient(['config', self.svn_base + 'trunk/src/'])
771 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] 772 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset']
772 self.assertEquals(0, self.gclient(cmd)[-1]) 773 self.assertEquals(0, self.gclient(cmd)[-1])
773 third_party = join(self.root_dir, 'src', 'third_party') 774 third_party = join(self.root_dir, 'src', 'third_party')
774 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], 775 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'],
775 cwd=third_party) 776 cwd=third_party)
776 777
777 # Cripple src/third_party/foo and make sure gclient still succeeds. 778 # Cripple src/third_party/foo and make sure gclient still succeeds.
778 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) 779 gclient_utils.rmtree(join(third_party, 'foo', '.svn'))
779 self.assertEquals(0, self.gclient(cmd)[-1]) 780 self.assertEquals(0, self.gclient(cmd + ['--force'])[-1])
781
782 def testSkipGitSvn(self):
783 # Check that gclient skips git-svn checkouts.
784 if not self.enabled:
785 return
786
787 # Create the .gclient file.
788 svn_url = self.svn_base + 'trunk/src'
789 self.gclient(['config', svn_url], cwd=self.root_dir)
790
791 # Create a git-svn checkout.
792 # Use check_output to hide the output from the subprocess.
793 subprocess2.check_output(['git', 'svn', 'clone', svn_url],
794 cwd=self.root_dir)
795
796 # Ensure that gclient skips the git-svn checkout.
797 stdout, stderr, rc = self.gclient(['sync', '--jobs', '1'])
798 self.assertEquals(rc, 0)
799 self.assertFalse(stderr)
800 self.assertTrue('________ src looks like git-svn; skipping.' in stdout)
801 self.checkBlock(stdout, [
802 ['running', self.root_dir],
803 ['running', os.path.join(self.root_dir, 'src', 'file', 'other')],
804 ['running', self.root_dir],
805 ['running', self.root_dir],
806 ['running', self.root_dir],
807 ['running', self.root_dir],
808 ['running', self.root_dir],
809 ])
810
811 # But, we still need the DEPS to be checked out...
812 foo_dir = os.path.join(self.root_dir, 'src', 'third_party', 'foo')
813 foo_rev = subprocess2.check_output(['svnversion', foo_dir]).strip()
814 self.assertEquals(foo_rev, '1')
815
816 other_dir = os.path.join(self.root_dir, 'src', 'other')
817 other_rev = subprocess2.check_output(['svnversion', other_dir]).strip()
818 self.assertEquals(other_rev, '2')
819
820 # Verify that the DEPS are NOT skipped on a second update.
821 stdout, stderr, rc = self.gclient(['sync', '--jobs', '1'])
822 self.assertFalse(stderr)
823 self.assertTrue('________ src looks like git-svn; skipping.' in stdout)
824 self.assertFalse(
825 '________ src/other looks like git-svn; skipping.' in stdout,
826 'Non git-svn checkout is incorrectly skipped.')
827 self.assertFalse(
828 '________ src/third_party/foo looks like git-svn; skipping.' in stdout,
829 'Non git-svn checkout is incorrectly skipped.')
780 830
781 831
782 class GClientSmokeSVNTransitive(GClientSmokeBase): 832 class GClientSmokeSVNTransitive(GClientSmokeBase):
783 FAKE_REPOS_CLASS = FakeRepoTransitive 833 FAKE_REPOS_CLASS = FakeRepoTransitive
784 834
785 def setUp(self): 835 def setUp(self):
786 super(GClientSmokeSVNTransitive, self).setUp() 836 super(GClientSmokeSVNTransitive, self).setUp()
787 self.enabled = self.FAKE_REPOS.set_up_svn() 837 self.enabled = self.FAKE_REPOS.set_up_svn()
788 838
789 def testSyncTransitive(self): 839 def testSyncTransitive(self):
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1146
1097 # Pre-DEPS hooks don't run with runhooks. 1147 # Pre-DEPS hooks don't run with runhooks.
1098 self.gclient(['runhooks', '--deps', 'mac']) 1148 self.gclient(['runhooks', '--deps', 'mac'])
1099 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1149 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1100 ('repo_1@2', 'src/repo1'), 1150 ('repo_1@2', 'src/repo1'),
1101 ('repo_2@1', 'src/repo2') 1151 ('repo_2@1', 'src/repo2')
1102 ) 1152 )
1103 self.assertTree(tree) 1153 self.assertTree(tree)
1104 1154
1105 # Pre-DEPS hooks run when syncing with --nohooks. 1155 # Pre-DEPS hooks run when syncing with --nohooks.
1106 self.gclient(['sync', '--deps', 'mac', '--nohooks', 1156 self.gclient(['sync', '--deps', 'mac', '--nohooks', '--force',
1107 '--revision', 'src@' + self.githash('repo_5', 2)]) 1157 '--revision', 'src@' + self.githash('repo_5', 2)])
1108 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1158 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1109 ('repo_1@2', 'src/repo1'), 1159 ('repo_1@2', 'src/repo1'),
1110 ('repo_2@1', 'src/repo2') 1160 ('repo_2@1', 'src/repo2')
1111 ) 1161 )
1112 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' 1162 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked'
1113 self.assertTree(tree) 1163 self.assertTree(tree)
1114 1164
1115 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) 1165 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked'))
1116 1166
1117 # Pre-DEPS hooks don't run with --noprehooks 1167 # Pre-DEPS hooks don't run with --noprehooks
1118 self.gclient(['sync', '--deps', 'mac', '--noprehooks', 1168 self.gclient(['sync', '--deps', 'mac', '--noprehooks', '--force',
1119 '--revision', 'src@' + self.githash('repo_5', 2)]) 1169 '--revision', 'src@' + self.githash('repo_5', 2)])
1120 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1170 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1121 ('repo_1@2', 'src/repo1'), 1171 ('repo_1@2', 'src/repo1'),
1122 ('repo_2@1', 'src/repo2') 1172 ('repo_2@1', 'src/repo2')
1123 ) 1173 )
1124 self.assertTree(tree) 1174 self.assertTree(tree)
1125 1175
1126 def testPreDepsHooksError(self): 1176 def testPreDepsHooksError(self):
1127 if not self.enabled: 1177 if not self.enabled:
1128 return 1178 return
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 ('svn', 'trunk/other', 'src/other'), 1386 ('svn', 'trunk/other', 'src/other'),
1337 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), 1387 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'),
1338 ('git', 'repo_3', 'src/repo2/repo_renamed'), 1388 ('git', 'repo_3', 'src/repo2/repo_renamed'),
1339 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), 1389 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'),
1340 ] 1390 ]
1341 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) 1391 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path))
1342 for (scm, url, path) in expected_source] 1392 for (scm, url, path) in expected_source]
1343 1393
1344 self.assertEquals(sorted(entries), sorted(expected)) 1394 self.assertEquals(sorted(entries), sorted(expected))
1345 1395
1396 # TODO(borenet): Enable this at the same time that the guard is removed in
1397 # gclient.
1398 if (os.environ.get('CHROME_HEADLESS') and
1399 socket.gethostname() in ('vm859-m1', 'build1-m1', 'vm630-m1')):
1400 def testDeleteConflictingCheckout(self):
1401 if not self.enabled:
1402 return
1403
1404 # Create an initial svn checkout.
1405 self.gclient(['config', '--spec',
1406 'solutions=['
1407 '{"name": "src",'
1408 ' "url": "' + self.svn_base + 'trunk/src"},'
1409 ']'
1410 ])
1411 results = self.gclient(['sync', '--deps', 'mac'])
1412 self.assertEqual(results[2], 0, 'Sync failed!')
1413
1414 # Verify that we have the expected svn checkout.
1415 results = self.gclient(['revinfo', '--deps', 'mac'])
1416 actual = results[0].splitlines()
1417 expected = [
1418 'src: %strunk/src' % self.svn_base,
1419 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1420 'src/other: %strunk/other' % self.svn_base,
1421 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1422 ]
1423 self.assertEquals(actual, expected)
1424
1425 # Change the desired checkout to git.
1426 self.gclient(['config', '--spec',
1427 'solutions=['
1428 '{"name": "src",'
1429 ' "url": "' + self.git_base + 'repo_1"},'
1430 ']'
1431 ])
1432
1433 # Verify that the sync succeeds with --force.
1434 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1435 self.assertEqual(results[2], 0, 'Sync failed!')
1436
1437 # Verify that we got the desired git checkout.
1438 results = self.gclient(['revinfo', '--deps', 'mac'])
1439 actual = results[0].splitlines()
1440 expected = [
1441 'src: %srepo_1' % self.git_base,
1442 'src/repo2: %srepo_2@%s' % (self.git_base,
1443 self.githash('repo_2', 1)[:7]),
1444 'src/repo2/repo_renamed: %srepo_3' % self.git_base,
1445 ]
1446 self.assertEquals(actual, expected)
1447
1448 # Change the desired checkout back to svn.
1449 self.gclient(['config', '--spec',
1450 'solutions=['
1451 '{"name": "src",'
1452 ' "url": "' + self.svn_base + 'trunk/src"},'
1453 ']'
1454 ])
1455
1456 # Verify that the sync succeeds.
1457 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1458 self.assertEqual(results[2], 0, 'Sync failed!')
1459
1460 # Verify that we have the expected svn checkout.
1461 results = self.gclient(['revinfo', '--deps', 'mac'])
1462 actual = results[0].splitlines()
1463 expected = [
1464 'src: %strunk/src' % self.svn_base,
1465 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1466 'src/other: %strunk/other' % self.svn_base,
1467 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1468 ]
1469 self.assertEquals(actual, expected)
1470
1346 1471
1347 class GClientSmokeFromCheckout(GClientSmokeBase): 1472 class GClientSmokeFromCheckout(GClientSmokeBase):
1348 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. 1473 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1349 def setUp(self): 1474 def setUp(self):
1350 super(GClientSmokeFromCheckout, self).setUp() 1475 super(GClientSmokeFromCheckout, self).setUp()
1351 self.enabled = self.FAKE_REPOS.set_up_svn() 1476 self.enabled = self.FAKE_REPOS.set_up_svn()
1352 os.rmdir(self.root_dir) 1477 os.rmdir(self.root_dir)
1353 if self.enabled: 1478 if self.enabled:
1354 usr, pwd = self.FAKE_REPOS.USERS[0] 1479 usr, pwd = self.FAKE_REPOS.USERS[0]
1355 subprocess2.check_call( 1480 subprocess2.check_call(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 1569
1445 if '-c' in sys.argv: 1570 if '-c' in sys.argv:
1446 COVERAGE = True 1571 COVERAGE = True
1447 sys.argv.remove('-c') 1572 sys.argv.remove('-c')
1448 if os.path.exists('.coverage'): 1573 if os.path.exists('.coverage'):
1449 os.remove('.coverage') 1574 os.remove('.coverage')
1450 os.environ['COVERAGE_FILE'] = os.path.join( 1575 os.environ['COVERAGE_FILE'] = os.path.join(
1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1576 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1452 '.coverage') 1577 '.coverage')
1453 unittest.main() 1578 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