| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 # Make path lower case since casing can change randomly. | 136 # Make path lower case since casing can change randomly. |
| 137 self.checkString( | 137 self.checkString( |
| 138 results[i][0][2].lower(), | 138 results[i][0][2].lower(), |
| 139 path.lower(), | 139 path.lower(), |
| 140 (i, results[i][0][2].lower(), path.lower())) | 140 (i, results[i][0][2].lower(), path.lower())) |
| 141 else: | 141 else: |
| 142 self.checkString(results[i][0][2], path, (i, results[i][0][2], path)) | 142 self.checkString(results[i][0][2], path, (i, results[i][0][2], path)) |
| 143 self.assertEquals(len(results), len(items), (stdout, items, len(results))) | 143 self.assertEquals(len(results), len(items), (stdout, items, len(results))) |
| 144 return results | 144 return results |
| 145 | 145 |
| 146 @staticmethod | |
| 147 def svnBlockCleanup(out): | |
| 148 """Work around svn status difference between svn 1.5 and svn 1.6 | |
| 149 I don't know why but on Windows they are reversed. So sorts the items.""" | |
| 150 for i in xrange(len(out)): | |
| 151 if len(out[i]) < 2: | |
| 152 continue | |
| 153 out[i] = [out[i][0]] + sorted([x[1:].strip() for x in out[i][1:]]) | |
| 154 return out | |
| 155 | |
| 156 | 146 |
| 157 class GClientSmoke(GClientSmokeBase): | 147 class GClientSmoke(GClientSmokeBase): |
| 158 """Doesn't require git-daemon.""" | 148 """Doesn't require git-daemon.""" |
| 159 @property | 149 @property |
| 160 def git_base(self): | 150 def git_base(self): |
| 161 return 'git://random.server/git/' | 151 return 'git://random.server/git/' |
| 162 | 152 |
| 163 def testHelp(self): | 153 def testHelp(self): |
| 164 """testHelp: make sure no new command was added.""" | 154 """testHelp: make sure no new command was added.""" |
| 165 result = self.gclient(['help']) | 155 result = self.gclient(['help']) |
| 166 # Roughly, not too short, not too long. | 156 # Roughly, not too short, not too long. |
| 167 self.assertTrue(1000 < len(result[0]) and len(result[0]) < 2300, | 157 self.assertTrue(1000 < len(result[0]) and len(result[0]) < 2300, |
| 168 'Too much written to stdout: %d bytes' % len(result[0])) | 158 'Too much written to stdout: %d bytes' % len(result[0])) |
| 169 self.assertEquals(0, len(result[1])) | 159 self.assertEquals(0, len(result[1])) |
| 170 self.assertEquals(0, result[2]) | 160 self.assertEquals(0, result[2]) |
| 171 | 161 |
| 172 def testUnknown(self): | 162 def testUnknown(self): |
| 173 result = self.gclient(['foo']) | 163 result = self.gclient(['foo']) |
| 174 # Roughly, not too short, not too long. | 164 # Roughly, not too short, not too long. |
| 175 self.assertTrue(1000 < len(result[0]) and len(result[0]) < 2300, | 165 self.assertTrue(1000 < len(result[0]) and len(result[0]) < 2300, |
| 176 'Too much written to stdout: %d bytes' % len(result[0])) | 166 'Too much written to stdout: %d bytes' % len(result[0])) |
| 177 self.assertEquals(0, len(result[1])) | 167 self.assertEquals(0, len(result[1])) |
| 178 self.assertEquals(0, result[2]) | 168 self.assertEquals(0, result[2]) |
| 179 | 169 |
| 180 def testNotConfigured(self): | 170 def testNotConfigured(self): |
| 181 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) | 171 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) |
| 182 self.check(res, self.gclient(['cleanup'])) | |
| 183 self.check(res, self.gclient(['diff'])) | 172 self.check(res, self.gclient(['diff'])) |
| 184 self.check(res, self.gclient(['pack'])) | 173 self.check(res, self.gclient(['pack'])) |
| 185 self.check(res, self.gclient(['revert'])) | 174 self.check(res, self.gclient(['revert'])) |
| 186 self.check(res, self.gclient(['revinfo'])) | 175 self.check(res, self.gclient(['revinfo'])) |
| 187 self.check(res, self.gclient(['runhooks'])) | 176 self.check(res, self.gclient(['runhooks'])) |
| 188 self.check(res, self.gclient(['status'])) | 177 self.check(res, self.gclient(['status'])) |
| 189 self.check(res, self.gclient(['sync'])) | 178 self.check(res, self.gclient(['sync'])) |
| 190 self.check(res, self.gclient(['update'])) | 179 self.check(res, self.gclient(['update'])) |
| 191 | 180 |
| 192 def testConfig(self): | 181 def testConfig(self): |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 247 |
| 259 def testSolutionNone(self): | 248 def testSolutionNone(self): |
| 260 results = self.gclient(['config', '--spec', | 249 results = self.gclient(['config', '--spec', |
| 261 'solutions=[{"name": "./", "url": None}]']) | 250 'solutions=[{"name": "./", "url": None}]']) |
| 262 self.check(('', '', 0), results) | 251 self.check(('', '', 0), results) |
| 263 results = self.gclient(['sync']) | 252 results = self.gclient(['sync']) |
| 264 self.check(('', '', 0), results) | 253 self.check(('', '', 0), results) |
| 265 self.assertTree({}) | 254 self.assertTree({}) |
| 266 results = self.gclient(['revinfo']) | 255 results = self.gclient(['revinfo']) |
| 267 self.check(('./: None\n', '', 0), results) | 256 self.check(('./: None\n', '', 0), results) |
| 268 self.check(('', '', 0), self.gclient(['cleanup'])) | |
| 269 self.check(('', '', 0), self.gclient(['diff'])) | 257 self.check(('', '', 0), self.gclient(['diff'])) |
| 270 self.assertTree({}) | 258 self.assertTree({}) |
| 271 self.check(('', '', 0), self.gclient(['pack'])) | 259 self.check(('', '', 0), self.gclient(['pack'])) |
| 272 self.check(('', '', 0), self.gclient(['revert'])) | 260 self.check(('', '', 0), self.gclient(['revert'])) |
| 273 self.assertTree({}) | 261 self.assertTree({}) |
| 274 self.check(('', '', 0), self.gclient(['runhooks'])) | 262 self.check(('', '', 0), self.gclient(['runhooks'])) |
| 275 self.assertTree({}) | 263 self.assertTree({}) |
| 276 self.check(('', '', 0), self.gclient(['status'])) | 264 self.check(('', '', 0), self.gclient(['status'])) |
| 277 | 265 |
| 278 def testDifferentTopLevelDirectory(self): | 266 def testDifferentTopLevelDirectory(self): |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 888 |
| 901 if '-c' in sys.argv: | 889 if '-c' in sys.argv: |
| 902 COVERAGE = True | 890 COVERAGE = True |
| 903 sys.argv.remove('-c') | 891 sys.argv.remove('-c') |
| 904 if os.path.exists('.coverage'): | 892 if os.path.exists('.coverage'): |
| 905 os.remove('.coverage') | 893 os.remove('.coverage') |
| 906 os.environ['COVERAGE_FILE'] = os.path.join( | 894 os.environ['COVERAGE_FILE'] = os.path.join( |
| 907 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 895 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 908 '.coverage') | 896 '.coverage') |
| 909 unittest.main() | 897 unittest.main() |
| OLD | NEW |