Chromium Code Reviews| 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 | |
| 25 import scm | |
| 24 | 26 |
| 25 import subprocess2 | 27 import subprocess2 |
| 26 | 28 |
| 27 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') | 29 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') |
| 28 COVERAGE = False | 30 COVERAGE = False |
| 29 | 31 |
| 30 | 32 |
| 31 class GClientSmokeBase(FakeReposTestBase): | 33 class GClientSmokeBase(FakeReposTestBase): |
| 32 def setUp(self): | 34 def setUp(self): |
| 33 super(GClientSmokeBase, self).setUp() | 35 super(GClientSmokeBase, self).setUp() |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 return | 779 return |
| 778 self.gclient(['config', self.svn_base + 'trunk/src/']) | 780 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 779 self.gclient(['sync']) | 781 self.gclient(['sync']) |
| 780 # Cripple the checkout. | 782 # Cripple the checkout. |
| 781 os.remove(join(self.root_dir, '.gclient_entries')) | 783 os.remove(join(self.root_dir, '.gclient_entries')) |
| 782 src = join(self.root_dir, 'src') | 784 src = join(self.root_dir, 'src') |
| 783 res = self.gclient(['sync', '--jobs', '1'], src) | 785 res = self.gclient(['sync', '--jobs', '1'], src) |
| 784 self.checkBlock(res[0], | 786 self.checkBlock(res[0], |
| 785 ['running', 'running', 'running']) | 787 ['running', 'running', 'running']) |
| 786 | 788 |
| 789 def testUnversionedRepository(self): | |
| 790 # Check that gclient automatically deletes crippled SVN repositories. | |
| 791 if not self.enabled: | |
| 792 return | |
| 793 self.gclient(['config', self.svn_base + 'trunk/src/']) | |
| 794 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] | |
| 795 self.assertEquals(0, self.gclient(cmd)[-1]) | |
| 796 third_party = join(self.root_dir, 'src', 'third_party') | |
| 797 scm.SVN.Capture(['propset', 'svn:ignore', 'foo', '.'], cwd=third_party) | |
|
M-A Ruel
2012/11/14 20:59:29
I'd say to just subprocess it to avoid having to i
davidjames
2012/11/14 21:48:22
Done.
| |
| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1169 | 1185 |
| 1170 bases = {'svn': self.svn_base, 'git': self.git_base} | 1186 bases = {'svn': self.svn_base, 'git': self.git_base} |
| 1171 expected_source = [ | 1187 expected_source = [ |
| 1172 ('svn', 'trunk/src/', 'src'), | 1188 ('svn', 'trunk/src/', 'src'), |
| 1173 ('git', 'repo_1', 'src-git'), | 1189 ('git', 'repo_1', 'src-git'), |
| 1174 ('svn', 'trunk/other', 'src/other'), | 1190 ('svn', 'trunk/other', 'src/other'), |
| 1175 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), | 1191 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), |
| 1176 ('git', 'repo_3', 'src/repo2/repo_renamed'), | 1192 ('git', 'repo_3', 'src/repo2/repo_renamed'), |
| 1177 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), | 1193 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), |
| 1178 ] | 1194 ] |
| 1179 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) | 1195 expected = [(scm_, bases[scm_] + url, os.path.join(self.root_dir, path)) |
| 1180 for (scm, url, path) in expected_source] | 1196 for (scm_, url, path) in expected_source] |
| 1181 | 1197 |
| 1182 self.assertEquals(sorted(entries), sorted(expected)) | 1198 self.assertEquals(sorted(entries), sorted(expected)) |
| 1183 | 1199 |
| 1184 | 1200 |
| 1185 class GClientSmokeFromCheckout(GClientSmokeBase): | 1201 class GClientSmokeFromCheckout(GClientSmokeBase): |
| 1186 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1202 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
| 1187 def setUp(self): | 1203 def setUp(self): |
| 1188 super(GClientSmokeFromCheckout, self).setUp() | 1204 super(GClientSmokeFromCheckout, self).setUp() |
| 1189 self.enabled = self.FAKE_REPOS.set_up_svn() | 1205 self.enabled = self.FAKE_REPOS.set_up_svn() |
| 1190 os.rmdir(self.root_dir) | 1206 os.rmdir(self.root_dir) |
| (...skipping 91 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 |