| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 p = join(self.root_dir, '.gclient') | 198 p = join(self.root_dir, '.gclient') |
| 199 def test(cmd, expected): | 199 def test(cmd, expected): |
| 200 if os.path.exists(p): | 200 if os.path.exists(p): |
| 201 os.remove(p) | 201 os.remove(p) |
| 202 results = self.gclient(cmd) | 202 results = self.gclient(cmd) |
| 203 self.check(('', '', 0), results) | 203 self.check(('', '', 0), results) |
| 204 self.checkString(expected, open(p, 'rU').read()) | 204 self.checkString(expected, open(p, 'rU').read()) |
| 205 | 205 |
| 206 test(['config', self.svn_base + 'trunk/src/'], | 206 test(['config', self.svn_base + 'trunk/src/'], |
| 207 ('solutions = [\n' | 207 ('solutions = [\n' |
| 208 ' { "name" : "src",\n' | 208 ' {\n' |
| 209 ' "name" : "src",\n' |
| 209 ' "url" : "%strunk/src",\n' | 210 ' "url" : "%strunk/src",\n' |
| 210 ' "deps_file" : "DEPS",\n' | 211 ' "deps_file" : "DEPS",\n' |
| 211 ' "managed" : True,\n' | 212 ' "managed" : True,\n' |
| 212 ' "custom_deps" : {\n' | 213 ' "custom_deps" : {},\n' |
| 213 ' },\n' | |
| 214 ' "safesync_url": "",\n' | |
| 215 ' },\n' | 214 ' },\n' |
| 216 ']\n' | 215 ']\n' |
| 217 'cache_dir = None\n') % self.svn_base) | 216 'cache_dir = None\n') % self.svn_base) |
| 218 | 217 |
| 219 test(['config', self.git_base + 'repo_1', '--name', 'src'], | 218 test(['config', self.git_base + 'repo_1', '--name', 'src'], |
| 220 ('solutions = [\n' | 219 ('solutions = [\n' |
| 221 ' { "name" : "src",\n' | 220 ' {\n' |
| 221 ' "name" : "src",\n' |
| 222 ' "url" : "%srepo_1",\n' | 222 ' "url" : "%srepo_1",\n' |
| 223 ' "deps_file" : "DEPS",\n' | 223 ' "deps_file" : "DEPS",\n' |
| 224 ' "managed" : True,\n' | 224 ' "managed" : True,\n' |
| 225 ' "custom_deps" : {\n' | 225 ' "custom_deps" : {},\n' |
| 226 ' },\n' | |
| 227 ' "safesync_url": "",\n' | |
| 228 ' },\n' | 226 ' },\n' |
| 229 ']\n' | 227 ']\n' |
| 230 'cache_dir = None\n') % self.git_base) | 228 'cache_dir = None\n') % self.git_base) |
| 231 | 229 |
| 232 test(['config', 'foo', 'faa'], | 230 test(['config', 'foo', '--deps', 'blah'], |
| 233 'solutions = [\n' | 231 'solutions = [\n' |
| 234 ' { "name" : "foo",\n' | 232 ' {\n' |
| 233 ' "name" : "foo",\n' |
| 235 ' "url" : "foo",\n' | 234 ' "url" : "foo",\n' |
| 236 ' "deps_file" : "DEPS",\n' | 235 ' "deps_file" : "blah",\n' |
| 237 ' "managed" : True,\n' | 236 ' "managed" : True,\n' |
| 238 ' "custom_deps" : {\n' | 237 ' "custom_deps" : {},\n' |
| 239 ' },\n' | |
| 240 ' "safesync_url": "faa",\n' | |
| 241 ' },\n' | 238 ' },\n' |
| 242 ']\n' | 239 ']\n' |
| 243 'cache_dir = None\n') | 240 'cache_dir = None\n') |
| 244 | |
| 245 test(['config', 'foo', '--deps', 'blah'], | |
| 246 'solutions = [\n' | |
| 247 ' { "name" : "foo",\n' | |
| 248 ' "url" : "foo",\n' | |
| 249 ' "deps_file" : "blah",\n' | |
| 250 ' "managed" : True,\n' | |
| 251 ' "custom_deps" : {\n' | |
| 252 ' },\n' | |
| 253 ' "safesync_url": "",\n' | |
| 254 ' },\n' | |
| 255 ']\n' | |
| 256 'cache_dir = None\n') | |
| 257 | 241 |
| 258 test(['config', '--spec', '["blah blah"]'], '["blah blah"]') | 242 test(['config', '--spec', '["blah blah"]'], '["blah blah"]') |
| 259 | 243 |
| 260 os.remove(p) | 244 os.remove(p) |
| 261 results = self.gclient(['config', 'foo', 'faa', 'fuu']) | 245 results = self.gclient(['config', 'foo', 'faa', 'fuu']) |
| 262 err = ('Usage: gclient.py config [options] [url] [safesync url]\n\n' | 246 err = ('Usage: gclient.py config [options] [url]\n\n' |
| 263 'gclient.py: error: Inconsistent arguments. Use either --spec or one' | 247 'gclient.py: error: Inconsistent arguments. Use either --spec or one' |
| 264 ' or 2 args\n') | 248 ' or 2 args\n') |
| 265 self.check(('', err, 2), results) | 249 self.check(('', err, 2), results) |
| 266 self.assertFalse(os.path.exists(join(self.root_dir, '.gclient'))) | 250 self.assertFalse(os.path.exists(join(self.root_dir, '.gclient'))) |
| 267 | 251 |
| 268 def testSolutionNone(self): | 252 def testSolutionNone(self): |
| 269 results = self.gclient(['config', '--spec', | 253 results = self.gclient(['config', '--spec', |
| 270 'solutions=[{"name": "./", "url": None}]']) | 254 'solutions=[{"name": "./", "url": None}]']) |
| 271 self.check(('', '', 0), results) | 255 self.check(('', '', 0), results) |
| 272 results = self.gclient(['sync']) | 256 results = self.gclient(['sync']) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 299 | 283 |
| 300 | 284 |
| 301 class GClientSmokeGIT(GClientSmokeBase): | 285 class GClientSmokeGIT(GClientSmokeBase): |
| 302 def setUp(self): | 286 def setUp(self): |
| 303 super(GClientSmokeGIT, self).setUp() | 287 super(GClientSmokeGIT, self).setUp() |
| 304 self.enabled = self.FAKE_REPOS.set_up_git() | 288 self.enabled = self.FAKE_REPOS.set_up_git() |
| 305 | 289 |
| 306 def testSync(self): | 290 def testSync(self): |
| 307 if not self.enabled: | 291 if not self.enabled: |
| 308 return | 292 return |
| 309 # TODO(maruel): safesync. | |
| 310 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 293 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 311 # Test unversioned checkout. | 294 # Test unversioned checkout. |
| 312 self.parseGclient( | 295 self.parseGclient( |
| 313 ['sync', '--deps', 'mac', '--jobs', '1'], | 296 ['sync', '--deps', 'mac', '--jobs', '1'], |
| 314 ['running', 'running']) | 297 ['running', 'running']) |
| 315 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must | 298 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must |
| 316 # add sync parsing to get the list of updated files. | 299 # add sync parsing to get the list of updated files. |
| 317 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 300 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 318 ('repo_2@1', 'src/repo2'), | 301 ('repo_2@1', 'src/repo2'), |
| 319 ('repo_3@2', 'src/repo2/repo_renamed')) | 302 ('repo_3@2', 'src/repo2/repo_renamed')) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 []) | 362 []) |
| 380 tree = self.mangle_git_tree(('repo_1@1', 'src'), | 363 tree = self.mangle_git_tree(('repo_1@1', 'src'), |
| 381 ('repo_2@2', 'src/repo2'), | 364 ('repo_2@2', 'src/repo2'), |
| 382 ('repo_3@1', 'src/repo2/repo3'), | 365 ('repo_3@1', 'src/repo2/repo3'), |
| 383 ('repo_4@2', 'src/repo4')) | 366 ('repo_4@2', 'src/repo4')) |
| 384 self.assertTree(tree) | 367 self.assertTree(tree) |
| 385 | 368 |
| 386 def testSyncJobs(self): | 369 def testSyncJobs(self): |
| 387 if not self.enabled: | 370 if not self.enabled: |
| 388 return | 371 return |
| 389 # TODO(maruel): safesync. | |
| 390 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 372 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 391 # Test unversioned checkout. | 373 # Test unversioned checkout. |
| 392 self.parseGclient( | 374 self.parseGclient( |
| 393 ['sync', '--deps', 'mac', '--jobs', '8'], | 375 ['sync', '--deps', 'mac', '--jobs', '8'], |
| 394 ['running', 'running'], | 376 ['running', 'running'], |
| 395 untangle=True) | 377 untangle=True) |
| 396 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must | 378 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must |
| 397 # add sync parsing to get the list of updated files. | 379 # add sync parsing to get the list of updated files. |
| 398 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 380 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 399 ('repo_2@1', 'src/repo2'), | 381 ('repo_2@1', 'src/repo2'), |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 | 888 |
| 907 if '-c' in sys.argv: | 889 if '-c' in sys.argv: |
| 908 COVERAGE = True | 890 COVERAGE = True |
| 909 sys.argv.remove('-c') | 891 sys.argv.remove('-c') |
| 910 if os.path.exists('.coverage'): | 892 if os.path.exists('.coverage'): |
| 911 os.remove('.coverage') | 893 os.remove('.coverage') |
| 912 os.environ['COVERAGE_FILE'] = os.path.join( | 894 os.environ['COVERAGE_FILE'] = os.path.join( |
| 913 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 895 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 914 '.coverage') | 896 '.coverage') |
| 915 unittest.main() | 897 unittest.main() |
| OLD | NEW |