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...) Expand 10 before | Expand all | Expand 10 after 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 # Try to sync the new DEPS. Verify that the sync fails without --force. |
| 1447 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) |
| 1448 self.assertEquals(res[2], 1, 'New DEPS sync succeeded unexpectedly.') |
| 1449 |
| 1450 # Verify that the sync succeeds with --force. Verify that we have the |
| 1451 # expected merged checkout. |
| 1452 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3', |
| 1453 '--force']) |
| 1454 self.assertEqual(res[2], 0, 'DEPS change sync failed with --force.') |
| 1455 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1456 skia), skia_git_url) |
| 1457 |
| 1458 # Sync again. Verify that we still have the expected merged checkout. |
| 1459 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) |
| 1460 self.assertEqual(res[2], 0, 'Subsequent sync failed.') |
| 1461 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1462 skia), skia_git_url) |
| 1463 |
| 1464 # Sync back to the original DEPS. Verify that we get the original structure. |
| 1465 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2', |
| 1466 '--force']) |
| 1467 self.assertEqual(res[2], 0, 'Reverse sync failed.') |
| 1468 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1469 gyp_svn_url) |
| 1470 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1471 include_svn_url) |
| 1472 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1473 src_svn_url) |
| 1474 |
| 1475 # Sync again. Verify that we still have the original structure. |
| 1476 res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) |
| 1477 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') |
| 1478 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], |
| 1479 gyp_svn_url) |
| 1480 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], |
| 1481 include_svn_url) |
| 1482 self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], |
| 1483 src_svn_url) |
| 1484 |
| 1485 def testSkiaDEPSChangeGit(self): |
| 1486 if not self.enabled: |
| 1487 return |
| 1488 |
| 1489 # Create an initial checkout: |
| 1490 # - Single checkout at the root. |
| 1491 # - Multiple checkouts in a shared subdirectory. |
| 1492 self.gclient(['config', '--spec', |
| 1493 'solutions=[' |
| 1494 '{"name": "src",' |
| 1495 ' "url": "' + self.git_base + 'repo_2",' |
| 1496 '}]']) |
| 1497 |
| 1498 checkout_path = os.path.join(self.root_dir, 'src') |
| 1499 skia = os.path.join(checkout_path, 'third_party', 'skia') |
| 1500 skia_gyp = os.path.join(skia, 'gyp') |
| 1501 skia_include = os.path.join(skia, 'include') |
| 1502 skia_src = os.path.join(skia, 'src') |
| 1503 |
| 1504 gyp_git_url = self.git_base + 'repo_3' |
| 1505 include_git_url = self.git_base + 'repo_4' |
| 1506 src_git_url = self.git_base + 'repo_5' |
| 1507 skia_git_url = self.FAKE_REPOS.git_base + 'repo_1' |
| 1508 |
| 1509 pre_hash = self.githash('repo_2', 1) |
| 1510 post_hash = self.githash('repo_2', 2) |
| 1511 |
| 1512 # Initial sync. Verify that we get the expected checkout. |
| 1513 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1514 'src@%s' % pre_hash]) |
| 1515 self.assertEqual(res[2], 0, 'Initial sync failed.') |
| 1516 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1517 skia_gyp), gyp_git_url) |
| 1518 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1519 skia_include), include_git_url) |
| 1520 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1521 skia_src), src_git_url) |
| 1522 |
| 1523 # Try to sync the new DEPS. Verify that the sync fails without --force. |
| 1524 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1525 'src@%s' % post_hash]) |
| 1526 self.assertEquals(res[2], 1, 'New DEPS sync succeeded unexpectedly.') |
| 1527 |
| 1528 # Verify that the sync succeeds with --force. Verify that we have the |
| 1529 # expected merged checkout. |
| 1530 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1531 'src@%s' % post_hash, '--force']) |
| 1532 self.assertEqual(res[2], 0, 'DEPS change sync failed with --force.') |
| 1533 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1534 skia), skia_git_url) |
| 1535 |
| 1536 # Sync again. Verify that we still have the expected merged checkout. |
| 1537 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1538 'src@%s' % post_hash]) |
| 1539 self.assertEqual(res[2], 0, 'Subsequent sync failed.') |
| 1540 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1541 skia), skia_git_url) |
| 1542 |
| 1543 # Sync back to the original DEPS. Verify that we get the original structure. |
| 1544 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1545 'src@%s' % pre_hash, '--force']) |
| 1546 self.assertEqual(res[2], 0, 'Reverse sync 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 # Sync again. Verify that we still have the original structure. |
| 1555 res = self.gclient(['sync', '--deps', 'mac', '--revision', |
| 1556 'src@%s' % pre_hash]) |
| 1557 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') |
| 1558 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1559 skia_gyp), gyp_git_url) |
| 1560 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1561 skia_include), include_git_url) |
| 1562 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], |
| 1563 skia_src), src_git_url) |
| 1564 |
| 1565 |
1400 class GClientSmokeFromCheckout(GClientSmokeBase): | 1566 class GClientSmokeFromCheckout(GClientSmokeBase): |
1401 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1567 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
1402 def setUp(self): | 1568 def setUp(self): |
1403 super(GClientSmokeFromCheckout, self).setUp() | 1569 super(GClientSmokeFromCheckout, self).setUp() |
1404 self.enabled = self.FAKE_REPOS.set_up_svn() | 1570 self.enabled = self.FAKE_REPOS.set_up_svn() |
1405 os.rmdir(self.root_dir) | 1571 os.rmdir(self.root_dir) |
1406 if self.enabled: | 1572 if self.enabled: |
1407 usr, pwd = self.FAKE_REPOS.USERS[0] | 1573 usr, pwd = self.FAKE_REPOS.USERS[0] |
1408 subprocess2.check_call( | 1574 subprocess2.check_call( |
1409 ['svn', 'checkout', self.svn_base + '/trunk/webkit', | 1575 ['svn', 'checkout', self.svn_base + '/trunk/webkit', |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 | 1663 |
1498 if '-c' in sys.argv: | 1664 if '-c' in sys.argv: |
1499 COVERAGE = True | 1665 COVERAGE = True |
1500 sys.argv.remove('-c') | 1666 sys.argv.remove('-c') |
1501 if os.path.exists('.coverage'): | 1667 if os.path.exists('.coverage'): |
1502 os.remove('.coverage') | 1668 os.remove('.coverage') |
1503 os.environ['COVERAGE_FILE'] = os.path.join( | 1669 os.environ['COVERAGE_FILE'] = os.path.join( |
1504 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1670 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1505 '.coverage') | 1671 '.coverage') |
1506 unittest.main() | 1672 unittest.main() |
OLD | NEW |