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. |
(...skipping 10 matching lines...) Expand all Loading... |
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 subprocess2 | 26 import subprocess2 |
27 | 27 |
28 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') | 28 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') |
29 COVERAGE = False | 29 COVERAGE = False |
30 | 30 |
31 | |
32 class GClientSmokeBase(FakeReposTestBase): | 31 class GClientSmokeBase(FakeReposTestBase): |
33 def setUp(self): | 32 def setUp(self): |
34 super(GClientSmokeBase, self).setUp() | 33 super(GClientSmokeBase, self).setUp() |
35 # Make sure it doesn't try to auto update when testing! | 34 # Make sure it doesn't try to auto update when testing! |
36 self.env = os.environ.copy() | 35 self.env = os.environ.copy() |
37 self.env['DEPOT_TOOLS_UPDATE'] = '0' | 36 self.env['DEPOT_TOOLS_UPDATE'] = '0' |
38 | 37 |
39 def gclient(self, cmd, cwd=None): | 38 def gclient(self, cmd, cwd=None): |
40 if not cwd: | 39 if not cwd: |
41 cwd = self.root_dir | 40 cwd = self.root_dir |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 'src/repo2: %(base)srepo_2@%(hash2)s\n' | 1065 'src/repo2: %(base)srepo_2@%(hash2)s\n' |
1067 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % | 1066 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % |
1068 { | 1067 { |
1069 'base': self.git_base, | 1068 'base': self.git_base, |
1070 'hash1': self.githash('repo_1', 2), | 1069 'hash1': self.githash('repo_1', 2), |
1071 'hash2': self.githash('repo_2', 1), | 1070 'hash2': self.githash('repo_2', 1), |
1072 'hash3': self.githash('repo_3', 2), | 1071 'hash3': self.githash('repo_3', 2), |
1073 }) | 1072 }) |
1074 self.check((out, '', 0), results) | 1073 self.check((out, '', 0), results) |
1075 | 1074 |
| 1075 def testNonstandardRemoteRef(self): |
| 1076 if not self.enabled: |
| 1077 return |
| 1078 # Very Gerrit-y |
| 1079 self.gclient(['config', self.git_base + 'repo_6@refs/changes/12/1', |
| 1080 '--name', 'src']) |
| 1081 self.gclient(['sync', '--deps', 'mac']) |
| 1082 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 1083 out = ('src: %(base)srepo_6@refs/changes/12/1\n' % |
| 1084 { |
| 1085 'base': self.git_base, |
| 1086 }) |
| 1087 self.check((out, '', 0), results) |
| 1088 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) |
| 1089 out = ('src: %(base)srepo_6@%(hash6)s\n' % |
| 1090 { |
| 1091 'base': self.git_base, |
| 1092 'hash6': self.githash('repo_6', 2), |
| 1093 }) |
| 1094 self.check((out, '', 0), results) |
1076 | 1095 |
1077 class GClientSmokeGITMutates(GClientSmokeBase): | 1096 class GClientSmokeGITMutates(GClientSmokeBase): |
1078 """testRevertAndStatus mutates the git repo so move it to its own suite.""" | 1097 """testRevertAndStatus mutates the git repo so move it to its own suite.""" |
1079 def setUp(self): | 1098 def setUp(self): |
1080 super(GClientSmokeGITMutates, self).setUp() | 1099 super(GClientSmokeGITMutates, self).setUp() |
1081 self.enabled = self.FAKE_REPOS.set_up_git() | 1100 self.enabled = self.FAKE_REPOS.set_up_git() |
1082 | 1101 |
1083 def testRevertAndStatus(self): | 1102 def testRevertAndStatus(self): |
1084 if not self.enabled: | 1103 if not self.enabled: |
1085 return | 1104 return |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 | 1442 |
1424 if '-c' in sys.argv: | 1443 if '-c' in sys.argv: |
1425 COVERAGE = True | 1444 COVERAGE = True |
1426 sys.argv.remove('-c') | 1445 sys.argv.remove('-c') |
1427 if os.path.exists('.coverage'): | 1446 if os.path.exists('.coverage'): |
1428 os.remove('.coverage') | 1447 os.remove('.coverage') |
1429 os.environ['COVERAGE_FILE'] = os.path.join( | 1448 os.environ['COVERAGE_FILE'] = os.path.join( |
1430 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1449 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1431 '.coverage') | 1450 '.coverage') |
1432 unittest.main() | 1451 unittest.main() |
OLD | NEW |