| 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, FakeReposTestBase | 23 from testing_support.fake_repos import join, write, FakeReposTestBase |
| 24 import gclient_utils |
| 24 | 25 |
| 25 import subprocess2 | 26 import subprocess2 |
| 26 | 27 |
| 27 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') | 28 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') |
| 28 COVERAGE = False | 29 COVERAGE = False |
| 29 | 30 |
| 30 | 31 |
| 31 class GClientSmokeBase(FakeReposTestBase): | 32 class GClientSmokeBase(FakeReposTestBase): |
| 32 def setUp(self): | 33 def setUp(self): |
| 33 super(GClientSmokeBase, self).setUp() | 34 super(GClientSmokeBase, self).setUp() |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 return | 778 return |
| 778 self.gclient(['config', self.svn_base + 'trunk/src/']) | 779 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 779 self.gclient(['sync']) | 780 self.gclient(['sync']) |
| 780 # Cripple the checkout. | 781 # Cripple the checkout. |
| 781 os.remove(join(self.root_dir, '.gclient_entries')) | 782 os.remove(join(self.root_dir, '.gclient_entries')) |
| 782 src = join(self.root_dir, 'src') | 783 src = join(self.root_dir, 'src') |
| 783 res = self.gclient(['sync', '--jobs', '1'], src) | 784 res = self.gclient(['sync', '--jobs', '1'], src) |
| 784 self.checkBlock(res[0], | 785 self.checkBlock(res[0], |
| 785 ['running', 'running', 'running']) | 786 ['running', 'running', 'running']) |
| 786 | 787 |
| 788 def testUnversionedRepository(self): |
| 789 # Check that gclient automatically deletes crippled SVN repositories. |
| 790 if not self.enabled: |
| 791 return |
| 792 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 793 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] |
| 794 self.assertEquals(0, self.gclient(cmd)[-1]) |
| 795 third_party = join(self.root_dir, 'src', 'third_party') |
| 796 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], |
| 797 cwd=third_party) |
| 798 |
| 799 # Cripple src/third_party/foo and make sure gclient still succeeds. |
| 800 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) |
| 801 self.assertEquals(0, self.gclient(cmd)[-1]) |
| 802 |
| 787 | 803 |
| 788 class GClientSmokeGIT(GClientSmokeBase): | 804 class GClientSmokeGIT(GClientSmokeBase): |
| 789 def setUp(self): | 805 def setUp(self): |
| 790 super(GClientSmokeGIT, self).setUp() | 806 super(GClientSmokeGIT, self).setUp() |
| 791 self.enabled = self.FAKE_REPOS.set_up_git() | 807 self.enabled = self.FAKE_REPOS.set_up_git() |
| 792 | 808 |
| 793 def testSync(self): | 809 def testSync(self): |
| 794 if not self.enabled: | 810 if not self.enabled: |
| 795 return | 811 return |
| 796 # TODO(maruel): safesync. | 812 # TODO(maruel): safesync. |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 | 1298 |
| 1283 if '-c' in sys.argv: | 1299 if '-c' in sys.argv: |
| 1284 COVERAGE = True | 1300 COVERAGE = True |
| 1285 sys.argv.remove('-c') | 1301 sys.argv.remove('-c') |
| 1286 if os.path.exists('.coverage'): | 1302 if os.path.exists('.coverage'): |
| 1287 os.remove('.coverage') | 1303 os.remove('.coverage') |
| 1288 os.environ['COVERAGE_FILE'] = os.path.join( | 1304 os.environ['COVERAGE_FILE'] = os.path.join( |
| 1289 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1305 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 1290 '.coverage') | 1306 '.coverage') |
| 1291 unittest.main() | 1307 unittest.main() |
| OLD | NEW |