| 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 | 25 |
| 26 import gclient_utils | |
| 27 | |
| 28 import subprocess2 | 26 import subprocess2 |
| 29 | 27 |
| 30 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') | 28 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') |
| 31 COVERAGE = False | 29 COVERAGE = False |
| 32 | 30 |
| 33 | 31 |
| 34 class GClientSmokeBase(FakeReposTestBase): | 32 class GClientSmokeBase(FakeReposTestBase): |
| 35 def setUp(self): | 33 def setUp(self): |
| 36 super(GClientSmokeBase, self).setUp() | 34 super(GClientSmokeBase, self).setUp() |
| 37 # Make sure it doesn't try to auto update when testing! | 35 # Make sure it doesn't try to auto update when testing! |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 return | 754 return |
| 757 self.gclient(['config', self.svn_base + 'trunk/src/']) | 755 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 758 self.gclient(['sync']) | 756 self.gclient(['sync']) |
| 759 # Cripple the checkout. | 757 # Cripple the checkout. |
| 760 os.remove(join(self.root_dir, '.gclient_entries')) | 758 os.remove(join(self.root_dir, '.gclient_entries')) |
| 761 src = join(self.root_dir, 'src') | 759 src = join(self.root_dir, 'src') |
| 762 res = self.gclient(['sync', '--jobs', '1'], src) | 760 res = self.gclient(['sync', '--jobs', '1'], src) |
| 763 self.checkBlock(res[0], | 761 self.checkBlock(res[0], |
| 764 ['running', 'running', 'running']) | 762 ['running', 'running', 'running']) |
| 765 | 763 |
| 766 def testUnversionedRepository(self): | |
| 767 # Check that gclient automatically deletes crippled SVN repositories. | |
| 768 if not self.enabled: | |
| 769 return | |
| 770 self.gclient(['config', self.svn_base + 'trunk/src/']) | |
| 771 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] | |
| 772 self.assertEquals(0, self.gclient(cmd)[-1]) | |
| 773 third_party = join(self.root_dir, 'src', 'third_party') | |
| 774 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], | |
| 775 cwd=third_party) | |
| 776 | |
| 777 # Cripple src/third_party/foo and make sure gclient still succeeds. | |
| 778 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) | |
| 779 self.assertEquals(0, self.gclient(cmd)[-1]) | |
| 780 | |
| 781 | 764 |
| 782 class GClientSmokeSVNTransitive(GClientSmokeBase): | 765 class GClientSmokeSVNTransitive(GClientSmokeBase): |
| 783 FAKE_REPOS_CLASS = FakeRepoTransitive | 766 FAKE_REPOS_CLASS = FakeRepoTransitive |
| 784 | 767 |
| 785 def setUp(self): | 768 def setUp(self): |
| 786 super(GClientSmokeSVNTransitive, self).setUp() | 769 super(GClientSmokeSVNTransitive, self).setUp() |
| 787 self.enabled = self.FAKE_REPOS.set_up_svn() | 770 self.enabled = self.FAKE_REPOS.set_up_svn() |
| 788 | 771 |
| 789 def testSyncTransitive(self): | 772 def testSyncTransitive(self): |
| 790 if not self.enabled: | 773 if not self.enabled: |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 | 1423 |
| 1441 if '-c' in sys.argv: | 1424 if '-c' in sys.argv: |
| 1442 COVERAGE = True | 1425 COVERAGE = True |
| 1443 sys.argv.remove('-c') | 1426 sys.argv.remove('-c') |
| 1444 if os.path.exists('.coverage'): | 1427 if os.path.exists('.coverage'): |
| 1445 os.remove('.coverage') | 1428 os.remove('.coverage') |
| 1446 os.environ['COVERAGE_FILE'] = os.path.join( | 1429 os.environ['COVERAGE_FILE'] = os.path.join( |
| 1447 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1430 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 1448 '.coverage') | 1431 '.coverage') |
| 1449 unittest.main() | 1432 unittest.main() |
| OLD | NEW |