OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 self.check(res, self.gclient(['diff'])) | 138 self.check(res, self.gclient(['diff'])) |
139 self.check(res, self.gclient(['export', 'foo'])) | 139 self.check(res, self.gclient(['export', 'foo'])) |
140 self.check(res, self.gclient(['pack'])) | 140 self.check(res, self.gclient(['pack'])) |
141 self.check(res, self.gclient(['revert'])) | 141 self.check(res, self.gclient(['revert'])) |
142 self.check(res, self.gclient(['revinfo'])) | 142 self.check(res, self.gclient(['revinfo'])) |
143 self.check(res, self.gclient(['runhooks'])) | 143 self.check(res, self.gclient(['runhooks'])) |
144 self.check(res, self.gclient(['status'])) | 144 self.check(res, self.gclient(['status'])) |
145 self.check(res, self.gclient(['sync'])) | 145 self.check(res, self.gclient(['sync'])) |
146 self.check(res, self.gclient(['update'])) | 146 self.check(res, self.gclient(['update'])) |
147 | 147 |
| 148 def testWrongConfig(self): |
| 149 # tested in testConfig. |
| 150 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 151 other_src = join(self.root_dir, 'src-other') |
| 152 os.mkdir(other_src) |
| 153 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) |
| 154 self.check(res, self.gclient(['status'], other_src)) |
| 155 src = join(self.root_dir, 'src') |
| 156 os.mkdir(src) |
| 157 res = self.gclient(['status'], src) |
| 158 self.checkBlock(res[0], [('running', src)]) |
| 159 |
148 def testConfig(self): | 160 def testConfig(self): |
149 p = join(self.root_dir, '.gclient') | 161 p = join(self.root_dir, '.gclient') |
150 def test(cmd, expected): | 162 def test(cmd, expected): |
151 if os.path.exists(p): | 163 if os.path.exists(p): |
152 os.remove(p) | 164 os.remove(p) |
153 results = self.gclient(cmd) | 165 results = self.gclient(cmd) |
154 self.check(('', '', 0), results) | 166 self.check(('', '', 0), results) |
155 self.checkString(expected, open(p, 'rU').read()) | 167 self.checkString(expected, open(p, 'rU').read()) |
156 | 168 |
157 test(['config', self.svn_base + 'trunk/src/'], | 169 test(['config', self.svn_base + 'trunk/src/'], |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 if __name__ == '__main__': | 891 if __name__ == '__main__': |
880 if '-c' in sys.argv: | 892 if '-c' in sys.argv: |
881 COVERAGE = True | 893 COVERAGE = True |
882 sys.argv.remove('-c') | 894 sys.argv.remove('-c') |
883 if os.path.exists('.coverage'): | 895 if os.path.exists('.coverage'): |
884 os.remove('.coverage') | 896 os.remove('.coverage') |
885 os.environ['COVERAGE_FILE'] = os.path.join( | 897 os.environ['COVERAGE_FILE'] = os.path.join( |
886 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 898 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
887 '.coverage') | 899 '.coverage') |
888 unittest.main() | 900 unittest.main() |
OLD | NEW |