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 subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 import unittest | 18 import unittest |
19 | 19 |
20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
21 sys.path.insert(0, ROOT_DIR) | 21 sys.path.insert(0, ROOT_DIR) |
22 | 22 |
23 from testing_support.fake_repos import join, write | 23 from testing_support.fake_repos import join, write |
24 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive | 24 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive, \ |
| 25 FakeRepoSkiaDEPS |
| 26 |
| 27 import gclient_utils |
| 28 import scm as gclient_scm |
25 | 29 |
26 import subprocess2 | 30 import subprocess2 |
27 | 31 |
28 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') | 32 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') |
29 COVERAGE = False | 33 COVERAGE = False |
30 | 34 |
31 | 35 |
32 class GClientSmokeBase(FakeReposTestBase): | 36 class GClientSmokeBase(FakeReposTestBase): |
33 def setUp(self): | 37 def setUp(self): |
34 super(GClientSmokeBase, self).setUp() | 38 super(GClientSmokeBase, self).setUp() |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 return | 758 return |
755 self.gclient(['config', self.svn_base + 'trunk/src/']) | 759 self.gclient(['config', self.svn_base + 'trunk/src/']) |
756 self.gclient(['sync']) | 760 self.gclient(['sync']) |
757 # Cripple the checkout. | 761 # Cripple the checkout. |
758 os.remove(join(self.root_dir, '.gclient_entries')) | 762 os.remove(join(self.root_dir, '.gclient_entries')) |
759 src = join(self.root_dir, 'src') | 763 src = join(self.root_dir, 'src') |
760 res = self.gclient(['sync', '--jobs', '1'], src) | 764 res = self.gclient(['sync', '--jobs', '1'], src) |
761 self.checkBlock(res[0], | 765 self.checkBlock(res[0], |
762 ['running', 'running', 'running']) | 766 ['running', 'running', 'running']) |
763 | 767 |
| 768 def testUnversionedRepository(self): |
| 769 # Check that gclient automatically deletes crippled SVN repositories. |
| 770 if not self.enabled: |
| 771 return |
| 772 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 773 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] |
| 774 self.assertEquals(0, self.gclient(cmd)[-1]) |
| 775 third_party = join(self.root_dir, 'src', 'third_party') |
| 776 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], |
| 777 cwd=third_party) |
| 778 |
| 779 # Cripple src/third_party/foo and make sure gclient still succeeds. |
| 780 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) |
| 781 self.assertEquals(0, self.gclient(cmd)[-1]) |
| 782 |
764 | 783 |
765 class GClientSmokeSVNTransitive(GClientSmokeBase): | 784 class GClientSmokeSVNTransitive(GClientSmokeBase): |
766 FAKE_REPOS_CLASS = FakeRepoTransitive | 785 FAKE_REPOS_CLASS = FakeRepoTransitive |
767 | 786 |
768 def setUp(self): | 787 def setUp(self): |
769 super(GClientSmokeSVNTransitive, self).setUp() | 788 super(GClientSmokeSVNTransitive, self).setUp() |
770 self.enabled = self.FAKE_REPOS.set_up_svn() | 789 self.enabled = self.FAKE_REPOS.set_up_svn() |
771 | 790 |
772 def testSyncTransitive(self): | 791 def testSyncTransitive(self): |
773 if not self.enabled: | 792 if not self.enabled: |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), | 1335 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), |
1317 ('git', 'repo_3', 'src/repo2/repo_renamed'), | 1336 ('git', 'repo_3', 'src/repo2/repo_renamed'), |
1318 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), | 1337 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), |
1319 ] | 1338 ] |
1320 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) | 1339 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) |
1321 for (scm, url, path) in expected_source] | 1340 for (scm, url, path) in expected_source] |
1322 | 1341 |
1323 self.assertEquals(sorted(entries), sorted(expected)) | 1342 self.assertEquals(sorted(entries), sorted(expected)) |
1324 | 1343 |
1325 | 1344 |
| 1345 class SkiaDEPSTransitionSmokeTest(GClientSmokeBase): |
| 1346 """Simulate the behavior of bisect bots as they transition across the Skia |
| 1347 DEPS change.""" |
| 1348 |
| 1349 FAKE_REPOS_CLASS = FakeRepoSkiaDEPS |
| 1350 |
| 1351 def setUp(self): |
| 1352 super(SkiaDEPSTransitionSmokeTest, self).setUp() |
| 1353 self.enabled = self.FAKE_REPOS.set_up_git() and self.FAKE_REPOS.set_up_svn() |
| 1354 |
| 1355 def testSkiaDEPSChangeSVN(self): |
| 1356 if not self.enabled: |
| 1357 return |
| 1358 |
| 1359 # Create an initial checkout: |
| 1360 # - Single checkout at the root. |
| 1361 # - Multiple checkouts in a shared subdirectory. |
| 1362 self.gclient(['config', '--spec', |
| 1363 'solutions=[' |
| 1364 '{"name": "src",' |
| 1365 ' "url": "' + self.svn_base + 'trunk/src/",' |
| 1366 '}]']) |
| 1367 |
| 1368 checkout_path = os.path.join(self.root_dir, 'src') |
| 1369 skia = os.path.join(checkout_path, 'third_party', 'skia') |
| 1370 skia_gyp = os.path.join(skia, 'gyp') |
| 1371 skia_include = os.path.join(skia, 'include') |
| 1372 skia_src = os.path.join(skia, 'src') |
| 1373 |
| 1374 gyp_svn_url = self.svn_base + 'skia/gyp' |
| 1375 include_svn_url = self.svn_base + 'skia/include' |
| 1376 src_svn_url = self.svn_base + 'skia/src' |
| 1377 skia_git_url = self.git_base + 'repo_1' |
| 1378 |
| 1379 # Initial sync. Verify that we get the expected checkout. |
| 1380 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) |
| 1381 self.assertEqual(res[2], 0, 'Initial sync failed.') |
| 1382 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1383 gyp_svn_url) |
| 1384 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1385 include_svn_url) |
| 1386 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1387 src_svn_url) |
| 1388 |
| 1389 # Verify that the sync succeeds. Verify that we have the expected merged |
| 1390 # checkout. |
| 1391 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) |
| 1392 self.assertEqual(res[2], 0, 'DEPS change sync failed.') |
| 1393 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1394 skia), skia_git_url) |
| 1395 |
| 1396 # Sync again. Verify that we still have the expected merged checkout. |
| 1397 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) |
| 1398 self.assertEqual(res[2], 0, 'Subsequent sync failed.') |
| 1399 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1400 skia), skia_git_url) |
| 1401 |
| 1402 # Sync back to the original DEPS. Verify that we get the original structure. |
| 1403 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) |
| 1404 self.assertEqual(res[2], 0, 'Reverse sync failed.') |
| 1405 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1406 gyp_svn_url) |
| 1407 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1408 include_svn_url) |
| 1409 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1410 src_svn_url) |
| 1411 |
| 1412 # Sync again. Verify that we still have the original structure. |
| 1413 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) |
| 1414 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') |
| 1415 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1416 gyp_svn_url) |
| 1417 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1418 include_svn_url) |
| 1419 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1420 src_svn_url) |
| 1421 |
| 1422 def testSkiaDEPSChangeGit(self): |
| 1423 if not self.enabled: |
| 1424 return |
| 1425 |
| 1426 # Create an initial checkout: |
| 1427 # - Single checkout at the root. |
| 1428 # - Multiple checkouts in a shared subdirectory. |
| 1429 self.gclient(['config', '--spec', |
| 1430 'solutions=[' |
| 1431 '{"name": "src",' |
| 1432 ' "url": "' + self.git_base + 'repo_2",' |
| 1433 '}]']) |
| 1434 |
| 1435 checkout_path = os.path.join(self.root_dir, 'src') |
| 1436 skia = os.path.join(checkout_path, 'third_party', 'skia') |
| 1437 skia_gyp = os.path.join(skia, 'gyp') |
| 1438 skia_include = os.path.join(skia, 'include') |
| 1439 skia_src = os.path.join(skia, 'src') |
| 1440 |
| 1441 gyp_git_url = self.git_base + 'repo_3' |
| 1442 include_git_url = self.git_base + 'repo_4' |
| 1443 src_git_url = self.git_base + 'repo_5' |
| 1444 skia_git_url = self.FAKE_REPOS.git_base + 'repo_1' |
| 1445 |
| 1446 pre_hash = self.githash('repo_2', 1) |
| 1447 post_hash = self.githash('repo_2', 2) |
| 1448 |
| 1449 # Initial sync. Verify that we get the expected checkout. |
| 1450 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1451 'src@%s' % pre_hash]) |
| 1452 self.assertEqual(res[2], 0, 'Initial sync failed.') |
| 1453 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1454 skia_gyp), gyp_git_url) |
| 1455 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1456 skia_include), include_git_url) |
| 1457 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1458 skia_src), src_git_url) |
| 1459 |
| 1460 # Verify that the sync succeeds. Verify that we have the expected merged |
| 1461 # checkout. |
| 1462 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1463 'src@%s' % post_hash]) |
| 1464 self.assertEqual(res[2], 0, 'DEPS change sync failed.') |
| 1465 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1466 skia), skia_git_url) |
| 1467 |
| 1468 # Sync again. Verify that we still have the expected merged checkout. |
| 1469 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1470 'src@%s' % post_hash]) |
| 1471 self.assertEqual(res[2], 0, 'Subsequent sync failed.') |
| 1472 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1473 skia), skia_git_url) |
| 1474 |
| 1475 # Sync back to the original DEPS. Verify that we get the original structure. |
| 1476 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1477 'src@%s' % pre_hash]) |
| 1478 self.assertEqual(res[2], 0, 'Reverse sync failed.') |
| 1479 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1480 skia_gyp), gyp_git_url) |
| 1481 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1482 skia_include), include_git_url) |
| 1483 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1484 skia_src), src_git_url) |
| 1485 |
| 1486 # Sync again. Verify that we still have the original structure. |
| 1487 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1488 'src@%s' % pre_hash]) |
| 1489 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') |
| 1490 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1491 skia_gyp), gyp_git_url) |
| 1492 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1493 skia_include), include_git_url) |
| 1494 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1495 skia_src), src_git_url) |
| 1496 |
| 1497 |
1326 class GClientSmokeFromCheckout(GClientSmokeBase): | 1498 class GClientSmokeFromCheckout(GClientSmokeBase): |
1327 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1499 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
1328 def setUp(self): | 1500 def setUp(self): |
1329 super(GClientSmokeFromCheckout, self).setUp() | 1501 super(GClientSmokeFromCheckout, self).setUp() |
1330 self.enabled = self.FAKE_REPOS.set_up_svn() | 1502 self.enabled = self.FAKE_REPOS.set_up_svn() |
1331 os.rmdir(self.root_dir) | 1503 os.rmdir(self.root_dir) |
1332 if self.enabled: | 1504 if self.enabled: |
1333 usr, pwd = self.FAKE_REPOS.USERS[0] | 1505 usr, pwd = self.FAKE_REPOS.USERS[0] |
1334 subprocess2.check_call( | 1506 subprocess2.check_call( |
1335 ['svn', 'checkout', self.svn_base + '/trunk/webkit', | 1507 ['svn', 'checkout', self.svn_base + '/trunk/webkit', |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 | 1595 |
1424 if '-c' in sys.argv: | 1596 if '-c' in sys.argv: |
1425 COVERAGE = True | 1597 COVERAGE = True |
1426 sys.argv.remove('-c') | 1598 sys.argv.remove('-c') |
1427 if os.path.exists('.coverage'): | 1599 if os.path.exists('.coverage'): |
1428 os.remove('.coverage') | 1600 os.remove('.coverage') |
1429 os.environ['COVERAGE_FILE'] = os.path.join( | 1601 os.environ['COVERAGE_FILE'] = os.path.join( |
1430 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1602 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1431 '.coverage') | 1603 '.coverage') |
1432 unittest.main() | 1604 unittest.main() |
OLD | NEW |