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. |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 return | 756 return |
757 self.gclient(['config', self.svn_base + 'trunk/src/']) | 757 self.gclient(['config', self.svn_base + 'trunk/src/']) |
758 self.gclient(['sync']) | 758 self.gclient(['sync']) |
759 # Cripple the checkout. | 759 # Cripple the checkout. |
760 os.remove(join(self.root_dir, '.gclient_entries')) | 760 os.remove(join(self.root_dir, '.gclient_entries')) |
761 src = join(self.root_dir, 'src') | 761 src = join(self.root_dir, 'src') |
762 res = self.gclient(['sync', '--jobs', '1'], src) | 762 res = self.gclient(['sync', '--jobs', '1'], src) |
763 self.checkBlock(res[0], | 763 self.checkBlock(res[0], |
764 ['running', 'running', 'running']) | 764 ['running', 'running', 'running']) |
765 | 765 |
766 def testUnversionedRepository(self): | 766 def testUnversionedRepository(self): |
borenet
2013/11/25 13:55:42
I'm a little confused about what this is testing,
| |
767 # Check that gclient automatically deletes crippled SVN repositories. | 767 # Check that gclient automatically deletes crippled SVN repositories. |
768 if not self.enabled: | 768 if not self.enabled: |
769 return | 769 return |
770 self.gclient(['config', self.svn_base + 'trunk/src/']) | 770 self.gclient(['config', self.svn_base + 'trunk/src/']) |
771 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] | 771 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] |
772 self.assertEquals(0, self.gclient(cmd)[-1]) | 772 self.assertEquals(0, self.gclient(cmd)[-1]) |
773 third_party = join(self.root_dir, 'src', 'third_party') | 773 third_party = join(self.root_dir, 'src', 'third_party') |
774 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], | 774 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], |
775 cwd=third_party) | 775 cwd=third_party) |
776 | 776 |
777 # Cripple src/third_party/foo and make sure gclient still succeeds. | 777 # Cripple src/third_party/foo and make sure gclient still succeeds. |
778 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) | 778 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) |
779 self.assertEquals(0, self.gclient(cmd)[-1]) | 779 self.assertEquals(0, self.gclient(cmd + ['--force'])[-1]) |
780 | 780 |
781 | 781 |
782 class GClientSmokeSVNTransitive(GClientSmokeBase): | 782 class GClientSmokeSVNTransitive(GClientSmokeBase): |
783 FAKE_REPOS_CLASS = FakeRepoTransitive | 783 FAKE_REPOS_CLASS = FakeRepoTransitive |
784 | 784 |
785 def setUp(self): | 785 def setUp(self): |
786 super(GClientSmokeSVNTransitive, self).setUp() | 786 super(GClientSmokeSVNTransitive, self).setUp() |
787 self.enabled = self.FAKE_REPOS.set_up_svn() | 787 self.enabled = self.FAKE_REPOS.set_up_svn() |
788 | 788 |
789 def testSyncTransitive(self): | 789 def testSyncTransitive(self): |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1060 ['running', 'running']) | 1060 ['running', 'running']) |
1061 self.assertEquals(1, len(out[0])) | 1061 self.assertEquals(1, len(out[0])) |
1062 self.assertEquals(1, len(out[1])) | 1062 self.assertEquals(1, len(out[1])) |
1063 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 1063 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
1064 ('repo_2@1', 'src/repo2'), | 1064 ('repo_2@1', 'src/repo2'), |
1065 ('repo_3@2', 'src/repo2/repo_renamed')) | 1065 ('repo_3@2', 'src/repo2/repo_renamed')) |
1066 tree['src/git_hooked1'] = 'git_hooked1' | 1066 tree['src/git_hooked1'] = 'git_hooked1' |
1067 tree['src/git_hooked2'] = 'git_hooked2' | 1067 tree['src/git_hooked2'] = 'git_hooked2' |
1068 self.assertTree(tree) | 1068 self.assertTree(tree) |
1069 | 1069 |
1070 def testPreDepsHooks(self): | 1070 def testPreDepsHooks(self): |
borenet
2013/11/25 13:55:42
This test is removed in https://codereview.chromiu
| |
1071 if not self.enabled: | 1071 if not self.enabled: |
1072 return | 1072 return |
1073 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) | 1073 self.gclient(['config', self.git_base + 'repo_5', '--name', 'src']) |
1074 expectation = [ | 1074 expectation = [ |
1075 ('running', self.root_dir), # git clone repo_5 | 1075 ('running', self.root_dir), # git clone repo_5 |
1076 ('running', self.root_dir + '/src'), # git checkout src | 1076 ('running', self.root_dir + '/src'), # git checkout src |
1077 ('running', self.root_dir), # pre-deps hook | 1077 ('running', self.root_dir), # pre-deps hook |
1078 ('running', self.root_dir), # git clone repo_1 | 1078 ('running', self.root_dir), # git clone repo_1 |
1079 ('running', self.root_dir + '/src/repo1'), # git checkout repo1 | 1079 ('running', self.root_dir + '/src/repo1'), # git checkout repo1 |
1080 ('running', self.root_dir), # git clone repo_1 | 1080 ('running', self.root_dir), # git clone repo_1 |
(...skipping 15 matching lines...) Expand all Loading... | |
1096 | 1096 |
1097 # Pre-DEPS hooks don't run with runhooks. | 1097 # Pre-DEPS hooks don't run with runhooks. |
1098 self.gclient(['runhooks', '--deps', 'mac']) | 1098 self.gclient(['runhooks', '--deps', 'mac']) |
1099 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1099 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
1100 ('repo_1@2', 'src/repo1'), | 1100 ('repo_1@2', 'src/repo1'), |
1101 ('repo_2@1', 'src/repo2') | 1101 ('repo_2@1', 'src/repo2') |
1102 ) | 1102 ) |
1103 self.assertTree(tree) | 1103 self.assertTree(tree) |
1104 | 1104 |
1105 # Pre-DEPS hooks run when syncing with --nohooks. | 1105 # Pre-DEPS hooks run when syncing with --nohooks. |
1106 self.gclient(['sync', '--deps', 'mac', '--nohooks', | 1106 self.gclient(['sync', '--deps', 'mac', '--nohooks', '--force', |
1107 '--revision', 'src@' + self.githash('repo_5', 2)]) | 1107 '--revision', 'src@' + self.githash('repo_5', 2)]) |
1108 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1108 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
1109 ('repo_1@2', 'src/repo1'), | 1109 ('repo_1@2', 'src/repo1'), |
1110 ('repo_2@1', 'src/repo2') | 1110 ('repo_2@1', 'src/repo2') |
1111 ) | 1111 ) |
1112 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' | 1112 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' |
1113 self.assertTree(tree) | 1113 self.assertTree(tree) |
1114 | 1114 |
1115 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) | 1115 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) |
1116 | 1116 |
1117 # Pre-DEPS hooks don't run with --noprehooks | 1117 # Pre-DEPS hooks don't run with --noprehooks |
1118 self.gclient(['sync', '--deps', 'mac', '--noprehooks', | 1118 self.gclient(['sync', '--deps', 'mac', '--noprehooks', '--force', |
1119 '--revision', 'src@' + self.githash('repo_5', 2)]) | 1119 '--revision', 'src@' + self.githash('repo_5', 2)]) |
1120 tree = self.mangle_git_tree(('repo_5@2', 'src'), | 1120 tree = self.mangle_git_tree(('repo_5@2', 'src'), |
1121 ('repo_1@2', 'src/repo1'), | 1121 ('repo_1@2', 'src/repo1'), |
1122 ('repo_2@1', 'src/repo2') | 1122 ('repo_2@1', 'src/repo2') |
1123 ) | 1123 ) |
1124 self.assertTree(tree) | 1124 self.assertTree(tree) |
1125 | 1125 |
1126 def testPreDepsHooksError(self): | 1126 def testPreDepsHooksError(self): |
1127 if not self.enabled: | 1127 if not self.enabled: |
1128 return | 1128 return |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 ('svn', 'trunk/other', 'src/other'), | 1336 ('svn', 'trunk/other', 'src/other'), |
1337 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), | 1337 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), |
1338 ('git', 'repo_3', 'src/repo2/repo_renamed'), | 1338 ('git', 'repo_3', 'src/repo2/repo_renamed'), |
1339 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), | 1339 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), |
1340 ] | 1340 ] |
1341 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) | 1341 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) |
1342 for (scm, url, path) in expected_source] | 1342 for (scm, url, path) in expected_source] |
1343 | 1343 |
1344 self.assertEquals(sorted(entries), sorted(expected)) | 1344 self.assertEquals(sorted(entries), sorted(expected)) |
1345 | 1345 |
1346 def testDeleteConflictingCheckout(self): | |
1347 if not self.enabled: | |
1348 return | |
1349 | |
1350 # Create an initial svn checkout. | |
1351 self.gclient(['config', '--spec', | |
1352 'solutions=[' | |
1353 '{"name": "src",' | |
1354 ' "url": "' + self.svn_base + 'trunk/src"},' | |
1355 ']' | |
1356 ]) | |
1357 results = self.gclient(['sync', '--deps', 'mac']) | |
1358 self.assertEqual(results[2], 0, 'Sync failed!') | |
1359 | |
1360 # Verify that we have the expected svn checkout. | |
1361 results = self.gclient(['revinfo', '--deps', 'mac']) | |
1362 actual = results[0].splitlines() | |
1363 expected = [ | |
1364 'src: %strunk/src' % self.svn_base, | |
1365 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base, | |
1366 'src/other: %strunk/other' % self.svn_base, | |
1367 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base, | |
1368 ] | |
1369 self.assertEquals(actual, expected) | |
1370 | |
1371 # Change the desired checkout to git. | |
1372 self.gclient(['config', '--spec', | |
1373 'solutions=[' | |
1374 '{"name": "src",' | |
1375 ' "url": "' + self.git_base + 'repo_1"},' | |
1376 ']' | |
1377 ]) | |
1378 | |
1379 # Verify that the sync succeeds with --force. | |
1380 results = self.gclient(['sync', '--deps', 'mac', '--force']) | |
1381 self.assertEqual(results[2], 0, 'Sync failed!') | |
1382 | |
1383 # Verify that we got the desired git checkout. | |
1384 results = self.gclient(['revinfo', '--deps', 'mac']) | |
1385 actual = results[0].splitlines() | |
1386 expected = [ | |
1387 'src: %srepo_1' % self.git_base, | |
1388 'src/repo2: %srepo_2@%s' % (self.git_base, self.githash('repo_2', 1)[:7]), | |
1389 'src/repo2/repo_renamed: %srepo_3' % self.git_base, | |
1390 ] | |
1391 self.assertEquals(actual, expected) | |
1392 | |
1393 # Change the desired checkout back to svn. | |
1394 self.gclient(['config', '--spec', | |
1395 'solutions=[' | |
1396 '{"name": "src",' | |
1397 ' "url": "' + self.svn_base + 'trunk/src"},' | |
1398 ']' | |
1399 ]) | |
1400 | |
1401 # Verify that the sync succeeds. | |
1402 results = self.gclient(['sync', '--deps', 'mac', '--force']) | |
1403 self.assertEqual(results[2], 0, 'Sync failed!') | |
1404 | |
1405 # Verify that we have the expected svn checkout. | |
1406 results = self.gclient(['revinfo', '--deps', 'mac']) | |
1407 actual = results[0].splitlines() | |
1408 expected = [ | |
1409 'src: %strunk/src' % self.svn_base, | |
1410 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base, | |
1411 'src/other: %strunk/other' % self.svn_base, | |
1412 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base, | |
1413 ] | |
1414 self.assertEquals(actual, expected) | |
1415 | |
1346 | 1416 |
1347 class GClientSmokeFromCheckout(GClientSmokeBase): | 1417 class GClientSmokeFromCheckout(GClientSmokeBase): |
1348 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1418 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
1349 def setUp(self): | 1419 def setUp(self): |
1350 super(GClientSmokeFromCheckout, self).setUp() | 1420 super(GClientSmokeFromCheckout, self).setUp() |
1351 self.enabled = self.FAKE_REPOS.set_up_svn() | 1421 self.enabled = self.FAKE_REPOS.set_up_svn() |
1352 os.rmdir(self.root_dir) | 1422 os.rmdir(self.root_dir) |
1353 if self.enabled: | 1423 if self.enabled: |
1354 usr, pwd = self.FAKE_REPOS.USERS[0] | 1424 usr, pwd = self.FAKE_REPOS.USERS[0] |
1355 subprocess2.check_call( | 1425 subprocess2.check_call( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1444 | 1514 |
1445 if '-c' in sys.argv: | 1515 if '-c' in sys.argv: |
1446 COVERAGE = True | 1516 COVERAGE = True |
1447 sys.argv.remove('-c') | 1517 sys.argv.remove('-c') |
1448 if os.path.exists('.coverage'): | 1518 if os.path.exists('.coverage'): |
1449 os.remove('.coverage') | 1519 os.remove('.coverage') |
1450 os.environ['COVERAGE_FILE'] = os.path.join( | 1520 os.environ['COVERAGE_FILE'] = os.path.join( |
1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1521 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1452 '.coverage') | 1522 '.coverage') |
1453 unittest.main() | 1523 unittest.main() |
OLD | NEW |