OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 _ = subprocess2.check_output(['git', 'svn', 'clone', svn_url], | |
iannucci
2014/02/07 20:04:01
Er... why? Though I guess it's just a smoke test s
borenet
2014/02/07 20:36:10
I assume you're asking about check_output? I was
| |
793 cwd=self.root_dir) | |
794 | |
795 # Ensure that gclient skips the git-svn checkout. | |
796 stdout, stderr, rc = self.gclient(['sync', '--jobs', '1']) | |
797 self.assertEquals(rc, 0) | |
798 self.assertFalse(stderr) | |
799 self.assertTrue('________ src looks like git-svn; skipping.' in stdout) | |
800 self.checkBlock(stdout, [ | |
801 ['running', self.root_dir], | |
802 ['running', os.path.join(self.root_dir, 'src', 'file', 'other')], | |
803 ['running', self.root_dir], | |
804 ['running', self.root_dir], | |
805 ['running', self.root_dir], | |
806 ['running', self.root_dir], | |
807 ['running', self.root_dir], | |
808 ]) | |
809 | |
810 # But, we still need the DEPS to be checked out... | |
811 foo_dir = os.path.join(self.root_dir, 'src', 'third_party', 'foo') | |
812 foo_rev = subprocess2.check_output(['svnversion', foo_dir]).strip() | |
813 self.assertEquals(foo_rev, '1') | |
814 | |
815 other_dir = os.path.join(self.root_dir, 'src', 'other') | |
816 other_rev = subprocess2.check_output(['svnversion', other_dir]).strip() | |
817 self.assertEquals(other_rev, '2') | |
818 | |
819 # Verify that the DEPS are NOT skipped on a second update. | |
820 stdout, stderr, rc = self.gclient(['sync', '--jobs', '1']) | |
821 self.assertFalse(stderr) | |
822 self.assertTrue('________ src looks like git-svn; skipping.' in stdout) | |
823 self.assertFalse( | |
824 '________ src/other looks like git-svn; skipping.' in stdout, | |
825 'Non git-svn checkout is incorrectly skipped.') | |
826 self.assertFalse( | |
827 '________ src/third_party/foo looks like git-svn; skipping.' in stdout, | |
828 'Non git-svn checkout is incorrectly skipped.') | |
780 | 829 |
781 | 830 |
782 class GClientSmokeSVNTransitive(GClientSmokeBase): | 831 class GClientSmokeSVNTransitive(GClientSmokeBase): |
783 FAKE_REPOS_CLASS = FakeRepoTransitive | 832 FAKE_REPOS_CLASS = FakeRepoTransitive |
784 | 833 |
785 def setUp(self): | 834 def setUp(self): |
786 super(GClientSmokeSVNTransitive, self).setUp() | 835 super(GClientSmokeSVNTransitive, self).setUp() |
787 self.enabled = self.FAKE_REPOS.set_up_svn() | 836 self.enabled = self.FAKE_REPOS.set_up_svn() |
788 | 837 |
789 def testSyncTransitive(self): | 838 def testSyncTransitive(self): |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1096 | 1145 |
1097 # Pre-DEPS hooks don't run with runhooks. | 1146 # Pre-DEPS hooks don't run with runhooks. |
1098 self.gclient(['runhooks', '--deps', 'mac']) | 1147 self.gclient(['runhooks', '--deps', 'mac']) |
1099 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1148 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
1100 ('repo_1@2', 'src/repo1'), | 1149 ('repo_1@2', 'src/repo1'), |
1101 ('repo_2@1', 'src/repo2') | 1150 ('repo_2@1', 'src/repo2') |
1102 ) | 1151 ) |
1103 self.assertTree(tree) | 1152 self.assertTree(tree) |
1104 | 1153 |
1105 # Pre-DEPS hooks run when syncing with --nohooks. | 1154 # Pre-DEPS hooks run when syncing with --nohooks. |
1106 self.gclient(['sync', '--deps', 'mac', '--nohooks', | 1155 self.gclient(['sync', '--deps', 'mac', '--nohooks', '--force', |
1107 '--revision', 'src@' + self.githash('repo_5', 2)]) | 1156 '--revision', 'src@' + self.githash('repo_5', 2)]) |
1108 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1157 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
1109 ('repo_1@2', 'src/repo1'), | 1158 ('repo_1@2', 'src/repo1'), |
1110 ('repo_2@1', 'src/repo2') | 1159 ('repo_2@1', 'src/repo2') |
1111 ) | 1160 ) |
1112 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' | 1161 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' |
1113 self.assertTree(tree) | 1162 self.assertTree(tree) |
1114 | 1163 |
1115 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) | 1164 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) |
1116 | 1165 |
1117 # Pre-DEPS hooks don't run with --noprehooks | 1166 # Pre-DEPS hooks don't run with --noprehooks |
1118 self.gclient(['sync', '--deps', 'mac', '--noprehooks', | 1167 self.gclient(['sync', '--deps', 'mac', '--noprehooks', '--force', |
1119 '--revision', 'src@' + self.githash('repo_5', 2)]) | 1168 '--revision', 'src@' + self.githash('repo_5', 2)]) |
1120 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1169 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
1121 ('repo_1@2', 'src/repo1'), | 1170 ('repo_1@2', 'src/repo1'), |
1122 ('repo_2@1', 'src/repo2') | 1171 ('repo_2@1', 'src/repo2') |
1123 ) | 1172 ) |
1124 self.assertTree(tree) | 1173 self.assertTree(tree) |
1125 | 1174 |
1126 def testPreDepsHooksError(self): | 1175 def testPreDepsHooksError(self): |
1127 if not self.enabled: | 1176 if not self.enabled: |
1128 return | 1177 return |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 ('svn', 'trunk/other', 'src/other'), | 1385 ('svn', 'trunk/other', 'src/other'), |
1337 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), | 1386 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), |
1338 ('git', 'repo_3', 'src/repo2/repo_renamed'), | 1387 ('git', 'repo_3', 'src/repo2/repo_renamed'), |
1339 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), | 1388 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), |
1340 ] | 1389 ] |
1341 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) | 1390 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) |
1342 for (scm, url, path) in expected_source] | 1391 for (scm, url, path) in expected_source] |
1343 | 1392 |
1344 self.assertEquals(sorted(entries), sorted(expected)) | 1393 self.assertEquals(sorted(entries), sorted(expected)) |
1345 | 1394 |
1395 # TODO(borenet): Enable this at the same time that the guard is removed in | |
1396 # gclient. | |
1397 if (os.environ.get('CHROME_HEADLESS') and | |
1398 socket.gethostname() in ('vm859-m1', 'build1-m1', 'vm630-m1')): | |
1399 def testDeleteConflictingCheckout(self): | |
1400 if not self.enabled: | |
1401 return | |
1402 | |
1403 # Create an initial svn checkout. | |
1404 self.gclient(['config', '--spec', | |
1405 'solutions=[' | |
1406 '{"name": "src",' | |
1407 ' "url": "' + self.svn_base + 'trunk/src"},' | |
1408 ']' | |
1409 ]) | |
1410 results = self.gclient(['sync', '--deps', 'mac']) | |
1411 self.assertEqual(results[2], 0, 'Sync failed!') | |
1412 | |
1413 # Verify that we have the expected svn checkout. | |
1414 results = self.gclient(['revinfo', '--deps', 'mac']) | |
1415 actual = results[0].splitlines() | |
1416 expected = [ | |
1417 'src: %strunk/src' % self.svn_base, | |
1418 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base, | |
1419 'src/other: %strunk/other' % self.svn_base, | |
1420 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base, | |
1421 ] | |
1422 self.assertEquals(actual, expected) | |
1423 | |
1424 # Change the desired checkout to git. | |
1425 self.gclient(['config', '--spec', | |
1426 'solutions=[' | |
1427 '{"name": "src",' | |
1428 ' "url": "' + self.git_base + 'repo_1"},' | |
1429 ']' | |
1430 ]) | |
1431 | |
1432 # Verify that the sync succeeds with --force. | |
1433 results = self.gclient(['sync', '--deps', 'mac', '--force']) | |
1434 self.assertEqual(results[2], 0, 'Sync failed!') | |
1435 | |
1436 # Verify that we got the desired git checkout. | |
1437 results = self.gclient(['revinfo', '--deps', 'mac']) | |
1438 actual = results[0].splitlines() | |
1439 expected = [ | |
1440 'src: %srepo_1' % self.git_base, | |
1441 'src/repo2: %srepo_2@%s' % (self.git_base, | |
1442 self.githash('repo_2', 1)[:7]), | |
1443 'src/repo2/repo_renamed: %srepo_3' % self.git_base, | |
1444 ] | |
1445 self.assertEquals(actual, expected) | |
1446 | |
1447 # Change the desired checkout back to svn. | |
1448 self.gclient(['config', '--spec', | |
1449 'solutions=[' | |
1450 '{"name": "src",' | |
1451 ' "url": "' + self.svn_base + 'trunk/src"},' | |
1452 ']' | |
1453 ]) | |
1454 | |
1455 # Verify that the sync succeeds. | |
1456 results = self.gclient(['sync', '--deps', 'mac', '--force']) | |
1457 self.assertEqual(results[2], 0, 'Sync failed!') | |
1458 | |
1459 # Verify that we have the expected svn checkout. | |
1460 results = self.gclient(['revinfo', '--deps', 'mac']) | |
1461 actual = results[0].splitlines() | |
1462 expected = [ | |
1463 'src: %strunk/src' % self.svn_base, | |
1464 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base, | |
1465 'src/other: %strunk/other' % self.svn_base, | |
1466 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base, | |
1467 ] | |
1468 self.assertEquals(actual, expected) | |
1469 | |
1346 | 1470 |
1347 class GClientSmokeFromCheckout(GClientSmokeBase): | 1471 class GClientSmokeFromCheckout(GClientSmokeBase): |
1348 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1472 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
1349 def setUp(self): | 1473 def setUp(self): |
1350 super(GClientSmokeFromCheckout, self).setUp() | 1474 super(GClientSmokeFromCheckout, self).setUp() |
1351 self.enabled = self.FAKE_REPOS.set_up_svn() | 1475 self.enabled = self.FAKE_REPOS.set_up_svn() |
1352 os.rmdir(self.root_dir) | 1476 os.rmdir(self.root_dir) |
1353 if self.enabled: | 1477 if self.enabled: |
1354 usr, pwd = self.FAKE_REPOS.USERS[0] | 1478 usr, pwd = self.FAKE_REPOS.USERS[0] |
1355 subprocess2.check_call( | 1479 subprocess2.check_call( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1444 | 1568 |
1445 if '-c' in sys.argv: | 1569 if '-c' in sys.argv: |
1446 COVERAGE = True | 1570 COVERAGE = True |
1447 sys.argv.remove('-c') | 1571 sys.argv.remove('-c') |
1448 if os.path.exists('.coverage'): | 1572 if os.path.exists('.coverage'): |
1449 os.remove('.coverage') | 1573 os.remove('.coverage') |
1450 os.environ['COVERAGE_FILE'] = os.path.join( | 1574 os.environ['COVERAGE_FILE'] = os.path.join( |
1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1575 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1452 '.coverage') | 1576 '.coverage') |
1453 unittest.main() | 1577 unittest.main() |
OLD | NEW |