Chromium Code Reviews| 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 743 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]) |
| 780 | 781 |
| 781 | 782 |
| 782 class GClientSmokeSVNTransitive(GClientSmokeBase): | 783 class GClientSmokeSVNTransitive(GClientSmokeBase): |
| 783 FAKE_REPOS_CLASS = FakeRepoTransitive | 784 FAKE_REPOS_CLASS = FakeRepoTransitive |
| 784 | 785 |
| 785 def setUp(self): | 786 def setUp(self): |
| 786 super(GClientSmokeSVNTransitive, self).setUp() | 787 super(GClientSmokeSVNTransitive, self).setUp() |
| 787 self.enabled = self.FAKE_REPOS.set_up_svn() | 788 self.enabled = self.FAKE_REPOS.set_up_svn() |
| 788 | 789 |
| 789 def testSyncTransitive(self): | 790 def testSyncTransitive(self): |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 | 1097 |
| 1097 # Pre-DEPS hooks don't run with runhooks. | 1098 # Pre-DEPS hooks don't run with runhooks. |
| 1098 self.gclient(['runhooks', '--deps', 'mac']) | 1099 self.gclient(['runhooks', '--deps', 'mac']) |
| 1099 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1100 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
| 1100 ('repo_1@2', 'src/repo1'), | 1101 ('repo_1@2', 'src/repo1'), |
| 1101 ('repo_2@1', 'src/repo2') | 1102 ('repo_2@1', 'src/repo2') |
| 1102 ) | 1103 ) |
| 1103 self.assertTree(tree) | 1104 self.assertTree(tree) |
| 1104 | 1105 |
| 1105 # Pre-DEPS hooks run when syncing with --nohooks. | 1106 # Pre-DEPS hooks run when syncing with --nohooks. |
| 1106 self.gclient(['sync', '--deps', 'mac', '--nohooks', | 1107 self.gclient(['sync', '--deps', 'mac', '--nohooks', '--force', |
| 1107 '--revision', 'src@' + self.githash('repo_5', 2)]) | 1108 '--revision', 'src@' + self.githash('repo_5', 2)]) |
| 1108 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1109 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
| 1109 ('repo_1@2', 'src/repo1'), | 1110 ('repo_1@2', 'src/repo1'), |
| 1110 ('repo_2@1', 'src/repo2') | 1111 ('repo_2@1', 'src/repo2') |
| 1111 ) | 1112 ) |
| 1112 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' | 1113 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' |
| 1113 self.assertTree(tree) | 1114 self.assertTree(tree) |
| 1114 | 1115 |
| 1115 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) | 1116 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) |
| 1116 | 1117 |
| 1117 # Pre-DEPS hooks don't run with --noprehooks | 1118 # Pre-DEPS hooks don't run with --noprehooks |
| 1118 self.gclient(['sync', '--deps', 'mac', '--noprehooks', | 1119 self.gclient(['sync', '--deps', 'mac', '--noprehooks', '--force', |
| 1119 '--revision', 'src@' + self.githash('repo_5', 2)]) | 1120 '--revision', 'src@' + self.githash('repo_5', 2)]) |
| 1120 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1121 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
| 1121 ('repo_1@2', 'src/repo1'), | 1122 ('repo_1@2', 'src/repo1'), |
| 1122 ('repo_2@1', 'src/repo2') | 1123 ('repo_2@1', 'src/repo2') |
| 1123 ) | 1124 ) |
| 1124 self.assertTree(tree) | 1125 self.assertTree(tree) |
| 1125 | 1126 |
| 1126 def testPreDepsHooksError(self): | 1127 def testPreDepsHooksError(self): |
| 1127 if not self.enabled: | 1128 if not self.enabled: |
| 1128 return | 1129 return |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1336 ('svn', 'trunk/other', 'src/other'), | 1337 ('svn', 'trunk/other', 'src/other'), |
| 1337 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), | 1338 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), |
| 1338 ('git', 'repo_3', 'src/repo2/repo_renamed'), | 1339 ('git', 'repo_3', 'src/repo2/repo_renamed'), |
| 1339 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), | 1340 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), |
| 1340 ] | 1341 ] |
| 1341 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) | 1342 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) |
| 1342 for (scm, url, path) in expected_source] | 1343 for (scm, url, path) in expected_source] |
| 1343 | 1344 |
| 1344 self.assertEquals(sorted(entries), sorted(expected)) | 1345 self.assertEquals(sorted(entries), sorted(expected)) |
| 1345 | 1346 |
| 1347 # TODO(borenet): Enable this at the same time that the guard is removed in | |
| 1348 # gclient. | |
| 1349 if (os.environ.get('CHROME_HEADLESS') and | |
| 1350 socket.gethostname() in ('vm859-m1', 'build1-m1', 'vm630-m1')): | |
|
borenet
2014/01/14 21:49:45
This is very, very stupid, but since there's a gua
iannucci
2014/01/14 22:40:02
What about mocking socket.gethostname to return 'v
M-A Ruel
2014/01/14 22:46:09
Mock enable_deletion_of_conflicting_checkouts inst
borenet
2014/01/15 13:53:27
These are much better solutions. Unfortunately, s
| |
| 1351 def testDeleteConflictingCheckout(self): | |
| 1352 if not self.enabled: | |
| 1353 return | |
| 1354 | |
| 1355 # Create an initial svn checkout. | |
| 1356 self.gclient(['config', '--spec', | |
| 1357 'solutions=[' | |
| 1358 '{"name": "src",' | |
| 1359 ' "url": "' + self.svn_base + 'trunk/src"},' | |
| 1360 ']' | |
| 1361 ]) | |
| 1362 results = self.gclient(['sync', '--deps', 'mac']) | |
| 1363 self.assertEqual(results[2], 0, 'Sync failed!') | |
| 1364 | |
| 1365 # Verify that we have the expected svn checkout. | |
| 1366 results = self.gclient(['revinfo', '--deps', 'mac']) | |
| 1367 actual = results[0].splitlines() | |
| 1368 expected = [ | |
| 1369 'src: %strunk/src' % self.svn_base, | |
| 1370 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base, | |
| 1371 'src/other: %strunk/other' % self.svn_base, | |
| 1372 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base, | |
| 1373 ] | |
| 1374 self.assertEquals(actual, expected) | |
| 1375 | |
| 1376 # Change the desired checkout to git. | |
| 1377 self.gclient(['config', '--spec', | |
| 1378 'solutions=[' | |
| 1379 '{"name": "src",' | |
| 1380 ' "url": "' + self.git_base + 'repo_1"},' | |
| 1381 ']' | |
| 1382 ]) | |
| 1383 | |
| 1384 # Verify that the sync succeeds with --force. | |
| 1385 results = self.gclient(['sync', '--deps', 'mac', '--force']) | |
| 1386 self.assertEqual(results[2], 0, 'Sync failed!') | |
| 1387 | |
| 1388 # Verify that we got the desired git checkout. | |
| 1389 results = self.gclient(['revinfo', '--deps', 'mac']) | |
| 1390 actual = results[0].splitlines() | |
| 1391 expected = [ | |
| 1392 'src: %srepo_1' % self.git_base, | |
| 1393 'src/repo2: %srepo_2@%s' % (self.git_base, self.githash('repo_2', 1)[:7] ), | |
|
M-A Ruel
2014/01/14 22:46:09
80 cols
| |
| 1394 'src/repo2/repo_renamed: %srepo_3' % self.git_base, | |
| 1395 ] | |
| 1396 self.assertEquals(actual, expected) | |
| 1397 | |
| 1398 # Change the desired checkout back to svn. | |
| 1399 self.gclient(['config', '--spec', | |
| 1400 'solutions=[' | |
| 1401 '{"name": "src",' | |
| 1402 ' "url": "' + self.svn_base + 'trunk/src"},' | |
| 1403 ']' | |
| 1404 ]) | |
| 1405 | |
| 1406 # Verify that the sync succeeds. | |
| 1407 results = self.gclient(['sync', '--deps', 'mac', '--force']) | |
| 1408 self.assertEqual(results[2], 0, 'Sync failed!') | |
| 1409 | |
| 1410 # Verify that we have the expected svn checkout. | |
| 1411 results = self.gclient(['revinfo', '--deps', 'mac']) | |
| 1412 actual = results[0].splitlines() | |
| 1413 expected = [ | |
| 1414 'src: %strunk/src' % self.svn_base, | |
| 1415 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base, | |
| 1416 'src/other: %strunk/other' % self.svn_base, | |
| 1417 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base, | |
| 1418 ] | |
| 1419 self.assertEquals(actual, expected) | |
| 1420 | |
| 1346 | 1421 |
| 1347 class GClientSmokeFromCheckout(GClientSmokeBase): | 1422 class GClientSmokeFromCheckout(GClientSmokeBase): |
| 1348 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1423 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
| 1349 def setUp(self): | 1424 def setUp(self): |
| 1350 super(GClientSmokeFromCheckout, self).setUp() | 1425 super(GClientSmokeFromCheckout, self).setUp() |
| 1351 self.enabled = self.FAKE_REPOS.set_up_svn() | 1426 self.enabled = self.FAKE_REPOS.set_up_svn() |
| 1352 os.rmdir(self.root_dir) | 1427 os.rmdir(self.root_dir) |
| 1353 if self.enabled: | 1428 if self.enabled: |
| 1354 usr, pwd = self.FAKE_REPOS.USERS[0] | 1429 usr, pwd = self.FAKE_REPOS.USERS[0] |
| 1355 subprocess2.check_call( | 1430 subprocess2.check_call( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1444 | 1519 |
| 1445 if '-c' in sys.argv: | 1520 if '-c' in sys.argv: |
| 1446 COVERAGE = True | 1521 COVERAGE = True |
| 1447 sys.argv.remove('-c') | 1522 sys.argv.remove('-c') |
| 1448 if os.path.exists('.coverage'): | 1523 if os.path.exists('.coverage'): |
| 1449 os.remove('.coverage') | 1524 os.remove('.coverage') |
| 1450 os.environ['COVERAGE_FILE'] = os.path.join( | 1525 os.environ['COVERAGE_FILE'] = os.path.join( |
| 1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1526 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 1452 '.coverage') | 1527 '.coverage') |
| 1453 unittest.main() | 1528 unittest.main() |
| OLD | NEW |