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 |
25 | 26 |
26 import gclient_utils | 27 import gclient_utils |
| 28 import scm as gclient_scm |
27 | 29 |
28 import subprocess2 | 30 import subprocess2 |
29 | 31 |
30 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') | 32 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') |
31 COVERAGE = False | 33 COVERAGE = False |
32 | 34 |
33 | 35 |
34 class GClientSmokeBase(FakeReposTestBase): | 36 class GClientSmokeBase(FakeReposTestBase): |
35 def setUp(self): | 37 def setUp(self): |
36 super(GClientSmokeBase, self).setUp() | 38 super(GClientSmokeBase, self).setUp() |
(...skipping 1353 matching lines...) Loading... |
1390 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), | 1392 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), |
1391 ('git', 'repo_3', 'src/repo2/repo_renamed'), | 1393 ('git', 'repo_3', 'src/repo2/repo_renamed'), |
1392 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), | 1394 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), |
1393 ] | 1395 ] |
1394 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) | 1396 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) |
1395 for (scm, url, path) in expected_source] | 1397 for (scm, url, path) in expected_source] |
1396 | 1398 |
1397 self.assertEquals(sorted(entries), sorted(expected)) | 1399 self.assertEquals(sorted(entries), sorted(expected)) |
1398 | 1400 |
1399 | 1401 |
| 1402 class SkiaDEPSTransitionSmokeTest(GClientSmokeBase): |
| 1403 """Simulate the behavior of bisect bots as they transition across the Skia |
| 1404 DEPS change.""" |
| 1405 |
| 1406 FAKE_REPOS_CLASS = FakeRepoSkiaDEPS |
| 1407 |
| 1408 def setUp(self): |
| 1409 super(SkiaDEPSTransitionSmokeTest, self).setUp() |
| 1410 self.enabled = self.FAKE_REPOS.set_up_git() and self.FAKE_REPOS.set_up_svn() |
| 1411 |
| 1412 def testSkiaDEPSChangeSVN(self): |
| 1413 if not self.enabled: |
| 1414 return |
| 1415 |
| 1416 # Create an initial checkout: |
| 1417 # - Single checkout at the root. |
| 1418 # - Multiple checkouts in a shared subdirectory. |
| 1419 self.gclient(['config', '--spec', |
| 1420 'solutions=[' |
| 1421 '{"name": "src",' |
| 1422 ' "url": "' + self.svn_base + 'trunk/src/",' |
| 1423 '}]']) |
| 1424 |
| 1425 checkout_path = os.path.join(self.root_dir, 'src') |
| 1426 skia = os.path.join(checkout_path, 'third_party', 'skia') |
| 1427 skia_gyp = os.path.join(skia, 'gyp') |
| 1428 skia_include = os.path.join(skia, 'include') |
| 1429 skia_src = os.path.join(skia, 'src') |
| 1430 |
| 1431 gyp_svn_url = self.svn_base + 'skia/gyp' |
| 1432 include_svn_url = self.svn_base + 'skia/include' |
| 1433 src_svn_url = self.svn_base + 'skia/src' |
| 1434 skia_git_url = self.git_base + 'repo_1' |
| 1435 |
| 1436 # Initial sync. Verify that we get the expected checkout. |
| 1437 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) |
| 1438 self.assertEqual(res[2], 0, 'Initial sync failed.') |
| 1439 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1440 gyp_svn_url) |
| 1441 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1442 include_svn_url) |
| 1443 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1444 src_svn_url) |
| 1445 |
| 1446 # Verify that the sync succeeds. Verify that we have the expected merged |
| 1447 # checkout. |
| 1448 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) |
| 1449 self.assertEqual(res[2], 0, 'DEPS change sync failed.') |
| 1450 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1451 skia), skia_git_url) |
| 1452 |
| 1453 # Sync again. Verify that we still have the expected merged checkout. |
| 1454 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) |
| 1455 self.assertEqual(res[2], 0, 'Subsequent sync failed.') |
| 1456 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1457 skia), skia_git_url) |
| 1458 |
| 1459 # Sync back to the original DEPS. Verify that we get the original structure. |
| 1460 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) |
| 1461 self.assertEqual(res[2], 0, 'Reverse sync failed.') |
| 1462 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1463 gyp_svn_url) |
| 1464 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1465 include_svn_url) |
| 1466 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1467 src_svn_url) |
| 1468 |
| 1469 # Sync again. Verify that we still have the original structure. |
| 1470 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) |
| 1471 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') |
| 1472 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1473 gyp_svn_url) |
| 1474 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1475 include_svn_url) |
| 1476 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1477 src_svn_url) |
| 1478 |
| 1479 def testSkiaDEPSChangeGit(self): |
| 1480 if not self.enabled: |
| 1481 return |
| 1482 |
| 1483 # Create an initial checkout: |
| 1484 # - Single checkout at the root. |
| 1485 # - Multiple checkouts in a shared subdirectory. |
| 1486 self.gclient(['config', '--spec', |
| 1487 'solutions=[' |
| 1488 '{"name": "src",' |
| 1489 ' "url": "' + self.git_base + 'repo_2",' |
| 1490 '}]']) |
| 1491 |
| 1492 checkout_path = os.path.join(self.root_dir, 'src') |
| 1493 skia = os.path.join(checkout_path, 'third_party', 'skia') |
| 1494 skia_gyp = os.path.join(skia, 'gyp') |
| 1495 skia_include = os.path.join(skia, 'include') |
| 1496 skia_src = os.path.join(skia, 'src') |
| 1497 |
| 1498 gyp_git_url = self.git_base + 'repo_3' |
| 1499 include_git_url = self.git_base + 'repo_4' |
| 1500 src_git_url = self.git_base + 'repo_5' |
| 1501 skia_git_url = self.FAKE_REPOS.git_base + 'repo_1' |
| 1502 |
| 1503 pre_hash = self.githash('repo_2', 1) |
| 1504 post_hash = self.githash('repo_2', 2) |
| 1505 |
| 1506 # Initial sync. Verify that we get the expected checkout. |
| 1507 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1508 'src@%s' % pre_hash]) |
| 1509 self.assertEqual(res[2], 0, 'Initial sync failed.') |
| 1510 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1511 skia_gyp), gyp_git_url) |
| 1512 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1513 skia_include), include_git_url) |
| 1514 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1515 skia_src), src_git_url) |
| 1516 |
| 1517 # Verify that the sync succeeds. Verify that we have the expected merged |
| 1518 # checkout. |
| 1519 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1520 'src@%s' % post_hash]) |
| 1521 self.assertEqual(res[2], 0, 'DEPS change sync failed.') |
| 1522 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1523 skia), skia_git_url) |
| 1524 |
| 1525 # Sync again. Verify that we still have the expected merged checkout. |
| 1526 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1527 'src@%s' % post_hash]) |
| 1528 self.assertEqual(res[2], 0, 'Subsequent sync failed.') |
| 1529 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1530 skia), skia_git_url) |
| 1531 |
| 1532 # Sync back to the original DEPS. Verify that we get the original structure. |
| 1533 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1534 'src@%s' % pre_hash]) |
| 1535 self.assertEqual(res[2], 0, 'Reverse sync failed.') |
| 1536 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1537 skia_gyp), gyp_git_url) |
| 1538 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1539 skia_include), include_git_url) |
| 1540 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1541 skia_src), src_git_url) |
| 1542 |
| 1543 # Sync again. Verify that we still have the original structure. |
| 1544 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1545 'src@%s' % pre_hash]) |
| 1546 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') |
| 1547 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1548 skia_gyp), gyp_git_url) |
| 1549 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1550 skia_include), include_git_url) |
| 1551 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1552 skia_src), src_git_url) |
| 1553 |
| 1554 |
1400 class GClientSmokeFromCheckout(GClientSmokeBase): | 1555 class GClientSmokeFromCheckout(GClientSmokeBase): |
1401 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1556 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
1402 def setUp(self): | 1557 def setUp(self): |
1403 super(GClientSmokeFromCheckout, self).setUp() | 1558 super(GClientSmokeFromCheckout, self).setUp() |
1404 self.enabled = self.FAKE_REPOS.set_up_svn() | 1559 self.enabled = self.FAKE_REPOS.set_up_svn() |
1405 os.rmdir(self.root_dir) | 1560 os.rmdir(self.root_dir) |
1406 if self.enabled: | 1561 if self.enabled: |
1407 usr, pwd = self.FAKE_REPOS.USERS[0] | 1562 usr, pwd = self.FAKE_REPOS.USERS[0] |
1408 subprocess2.check_call( | 1563 subprocess2.check_call( |
1409 ['svn', 'checkout', self.svn_base + '/trunk/webkit', | 1564 ['svn', 'checkout', self.svn_base + '/trunk/webkit', |
(...skipping 87 matching lines...) Loading... |
1497 | 1652 |
1498 if '-c' in sys.argv: | 1653 if '-c' in sys.argv: |
1499 COVERAGE = True | 1654 COVERAGE = True |
1500 sys.argv.remove('-c') | 1655 sys.argv.remove('-c') |
1501 if os.path.exists('.coverage'): | 1656 if os.path.exists('.coverage'): |
1502 os.remove('.coverage') | 1657 os.remove('.coverage') |
1503 os.environ['COVERAGE_FILE'] = os.path.join( | 1658 os.environ['COVERAGE_FILE'] = os.path.join( |
1504 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1659 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1505 '.coverage') | 1660 '.coverage') |
1506 unittest.main() | 1661 unittest.main() |
OLD | NEW |