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