Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: tests/gclient_smoketest.py

Issue 910913003: Reland "Make gclient ready for the Blink (DEPS to main project)" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Undo populateGit deflake attemp in fake_repos.py Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/gclient_scm_test.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 FakeRepoSkiaDEPS, FakeRepoBlinkDEPS
26 26
27 import gclient_utils 27 import gclient_utils
28 import scm as gclient_scm 28 import scm as gclient_scm
29 29
30 import subprocess2 30 import subprocess2
31 31
32 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') 32 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient')
33 COVERAGE = False 33 COVERAGE = False
34 34
35 35
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 'src@%s' % pre_hash]) 1531 'src@%s' % pre_hash])
1532 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') 1532 self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.')
1533 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], 1533 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1534 skia_gyp), gyp_git_url) 1534 skia_gyp), gyp_git_url)
1535 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], 1535 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1536 skia_include), include_git_url) 1536 skia_include), include_git_url)
1537 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], 1537 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1538 skia_src), src_git_url) 1538 skia_src), src_git_url)
1539 1539
1540 1540
1541 class BlinkDEPSTransitionSmokeTest(GClientSmokeBase):
1542 """Simulate the behavior of bisect bots as they transition across the Blink
1543 DEPS change."""
1544
1545 FAKE_REPOS_CLASS = FakeRepoBlinkDEPS
1546
1547 def setUp(self):
1548 super(BlinkDEPSTransitionSmokeTest, self).setUp()
1549 self.enabled = self.FAKE_REPOS.set_up_git()
1550 self.checkout_path = os.path.join(self.root_dir, 'src')
1551 self.blink = os.path.join(self.checkout_path, 'third_party', 'WebKit')
1552 self.blink_git_url = self.FAKE_REPOS.git_base + 'repo_2'
1553 self.pre_merge_sha = self.githash('repo_1', 1)
1554 self.post_merge_sha = self.githash('repo_1', 2)
1555
1556 def CheckStatusPreMergePoint(self):
1557 self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'],
1558 self.blink), self.blink_git_url)
1559 self.assertTrue(os.path.exists(join(self.blink, '.git')))
1560 self.assertTrue(os.path.exists(join(self.blink, 'OWNERS')))
1561 with open(join(self.blink, 'OWNERS')) as f:
1562 owners_content = f.read()
1563 self.assertEqual('OWNERS-pre', owners_content, 'OWNERS not updated')
1564 self.assertTrue(os.path.exists(join(self.blink, 'Source', 'exists_always')))
1565 self.assertTrue(os.path.exists(
1566 join(self.blink, 'Source', 'exists_before_but_not_after')))
1567 self.assertFalse(os.path.exists(
1568 join(self.blink, 'Source', 'exists_after_but_not_before')))
1569
1570 def CheckStatusPostMergePoint(self):
1571 # Check that the contents still exists
1572 self.assertTrue(os.path.exists(join(self.blink, 'OWNERS')))
1573 with open(join(self.blink, 'OWNERS')) as f:
1574 owners_content = f.read()
1575 self.assertEqual('OWNERS-post', owners_content, 'OWNERS not updated')
1576 self.assertTrue(os.path.exists(join(self.blink, 'Source', 'exists_always')))
1577 # Check that file removed between the branch point are actually deleted.
1578 self.assertTrue(os.path.exists(
1579 join(self.blink, 'Source', 'exists_after_but_not_before')))
1580 self.assertFalse(os.path.exists(
1581 join(self.blink, 'Source', 'exists_before_but_not_after')))
1582 # But not the .git folder
1583 self.assertFalse(os.path.exists(join(self.blink, '.git')))
1584
1585 def testBlinkDEPSChangeUsingGclient(self):
1586 """Checks that {src,blink} repos are consistent when syncing going back and
1587 forth using gclient sync src@revision."""
1588 if not self.enabled:
1589 return
1590
1591 self.gclient(['config', '--spec',
1592 'solutions=['
1593 '{"name": "src",'
1594 ' "url": "' + self.git_base + 'repo_1",'
1595 '}]'])
1596
1597 # Go back and forth two times.
1598 for _ in xrange(2):
1599 res = self.gclient(['sync', '--jobs', '1',
1600 '--revision', 'src@%s' % self.pre_merge_sha])
1601 self.assertEqual(res[2], 0, 'DEPS change sync failed.')
1602 self.CheckStatusPreMergePoint()
1603
1604 res = self.gclient(['sync', '--jobs', '1',
1605 '--revision', 'src@%s' % self.post_merge_sha])
1606 self.assertEqual(res[2], 0, 'DEPS change sync failed.')
1607 self.CheckStatusPostMergePoint()
1608
1609
1610 def testBlinkDEPSChangeUsingGit(self):
1611 """Like testBlinkDEPSChangeUsingGclient, but move the main project using
1612 directly git and not gclient sync."""
1613 if not self.enabled:
1614 return
1615
1616 self.gclient(['config', '--spec',
1617 'solutions=['
1618 '{"name": "src",'
1619 ' "url": "' + self.git_base + 'repo_1",'
1620 ' "managed": False,'
1621 '}]'])
1622
1623 # Perform an initial sync to bootstrap the repo.
1624 res = self.gclient(['sync', '--jobs', '1'])
1625 self.assertEqual(res[2], 0, 'Initial gclient sync failed.')
1626
1627 # Go back and forth two times.
1628 for _ in xrange(2):
1629 subprocess2.check_call(['git', 'checkout', '-q', self.pre_merge_sha],
1630 cwd=self.checkout_path)
1631 res = self.gclient(['sync', '--jobs', '1'])
1632 self.assertEqual(res[2], 0, 'gclient sync failed.')
1633 self.CheckStatusPreMergePoint()
1634
1635 subprocess2.check_call(['git', 'checkout', '-q', self.post_merge_sha],
1636 cwd=self.checkout_path)
1637 res = self.gclient(['sync', '--jobs', '1'])
1638 self.assertEqual(res[2], 0, 'DEPS change sync failed.')
1639 self.CheckStatusPostMergePoint()
1640
1641
1642 def testBlinkLocalBranchesArePreserved(self):
1643 """Checks that the state of local git branches are effectively preserved
1644 when going back and forth."""
1645 if not self.enabled:
1646 return
1647
1648 self.gclient(['config', '--spec',
1649 'solutions=['
1650 '{"name": "src",'
1651 ' "url": "' + self.git_base + 'repo_1",'
1652 '}]'])
1653
1654 # Initialize to pre-merge point.
1655 self.gclient(['sync', '--revision', 'src@%s' % self.pre_merge_sha])
1656 self.CheckStatusPreMergePoint()
1657
1658 # Create a branch named "foo".
1659 subprocess2.check_call(['git', 'checkout', '-qB', 'foo'],
1660 cwd=self.blink)
1661
1662 # Cross the pre-merge point.
1663 self.gclient(['sync', '--revision', 'src@%s' % self.post_merge_sha])
1664 self.CheckStatusPostMergePoint()
1665
1666 # Go backwards and check that we still have the foo branch.
1667 self.gclient(['sync', '--revision', 'src@%s' % self.pre_merge_sha])
1668 self.CheckStatusPreMergePoint()
1669 subprocess2.check_call(
1670 ['git', 'show-ref', '-q', '--verify', 'refs/heads/foo'], cwd=self.blink)
1671
1672
1541 class GClientSmokeFromCheckout(GClientSmokeBase): 1673 class GClientSmokeFromCheckout(GClientSmokeBase):
1542 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. 1674 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1543 def setUp(self): 1675 def setUp(self):
1544 super(GClientSmokeFromCheckout, self).setUp() 1676 super(GClientSmokeFromCheckout, self).setUp()
1545 self.enabled = self.FAKE_REPOS.set_up_svn() 1677 self.enabled = self.FAKE_REPOS.set_up_svn()
1546 os.rmdir(self.root_dir) 1678 os.rmdir(self.root_dir)
1547 if self.enabled: 1679 if self.enabled:
1548 usr, pwd = self.FAKE_REPOS.USERS[0] 1680 usr, pwd = self.FAKE_REPOS.USERS[0]
1549 subprocess2.check_call( 1681 subprocess2.check_call(
1550 ['svn', 'checkout', self.svn_base + '/trunk/webkit', 1682 ['svn', 'checkout', self.svn_base + '/trunk/webkit',
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 1773
1642 if '-c' in sys.argv: 1774 if '-c' in sys.argv:
1643 COVERAGE = True 1775 COVERAGE = True
1644 sys.argv.remove('-c') 1776 sys.argv.remove('-c')
1645 if os.path.exists('.coverage'): 1777 if os.path.exists('.coverage'):
1646 os.remove('.coverage') 1778 os.remove('.coverage')
1647 os.environ['COVERAGE_FILE'] = os.path.join( 1779 os.environ['COVERAGE_FILE'] = os.path.join(
1648 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1780 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1649 '.coverage') 1781 '.coverage')
1650 unittest.main() 1782 unittest.main()
OLDNEW
« no previous file with comments | « tests/gclient_scm_test.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698