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 """Unit tests for gclient.py. | 6 """Unit tests for gclient.py. |
7 | 7 |
8 See gclient_smoketest.py for integration tests. | 8 See gclient_smoketest.py for integration tests. |
9 """ | 9 """ |
10 | 10 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 ' "unix": { "foo/dir2": "/dir2", },\n' | 299 ' "unix": { "foo/dir2": "/dir2", },\n' |
300 ' "baz": { "foo/dir3": "/dir3", },\n' | 300 ' "baz": { "foo/dir3": "/dir3", },\n' |
301 '}') | 301 '}') |
302 | 302 |
303 parser = gclient.Parser() | 303 parser = gclient.Parser() |
304 options, _ = parser.parse_args(['--jobs', '1']) | 304 options, _ = parser.parse_args(['--jobs', '1']) |
305 options.deps_os = "unix" | 305 options.deps_os = "unix" |
306 | 306 |
307 obj = gclient.GClient.LoadCurrentConfig(options) | 307 obj = gclient.GClient.LoadCurrentConfig(options) |
308 self.assertEqual(['baz', 'unix'], sorted(obj.enforced_os)) | 308 self.assertEqual(['baz', 'unix'], sorted(obj.enforced_os)) |
309 | 309 |
| 310 def testRecursionOverride(self): |
| 311 """Verifies that recursion variable allows gclient to pull additional deps. |
| 312 |
| 313 We only test the case of recursion override for top-level deps, as that is |
| 314 all we support. |
| 315 """ |
| 316 write( |
| 317 '.gclient', |
| 318 'solutions = [\n' |
| 319 ' { "name": "foo", "url": "svn://example.com/foo" },\n' |
| 320 ']') |
| 321 write( |
| 322 os.path.join('foo', 'DEPS'), |
| 323 'deps = {\n' |
| 324 ' "bar": "/bar",\n' |
| 325 '}\n' |
| 326 'recursion = 2') |
| 327 write( |
| 328 os.path.join('bar', 'DEPS'), |
| 329 'deps = {\n' |
| 330 ' "baz": "/baz",\n' |
| 331 '}') |
| 332 write( |
| 333 os.path.join('baz', 'DEPS'), |
| 334 'deps = {\n' |
| 335 ' "fizz": "/fizz",\n' |
| 336 '}') |
| 337 write( |
| 338 os.path.join('fizz', 'DEPS'), |
| 339 'deps = {\n' |
| 340 '}') |
| 341 |
| 342 options, _ = gclient.Parser().parse_args([]) |
| 343 obj = gclient.GClient.LoadCurrentConfig(options) |
| 344 obj.RunOnDeps('None', []) |
| 345 self.assertEquals( |
| 346 [ |
| 347 'svn://example.com/foo', |
| 348 'svn://example.com/foo/bar', |
| 349 'svn://example.com/foo/bar/baz', |
| 350 ], |
| 351 self._get_processed()) |
| 352 |
310 | 353 |
311 if __name__ == '__main__': | 354 if __name__ == '__main__': |
312 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 355 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
313 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 356 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
314 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 357 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
315 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 358 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
316 logging.basicConfig( | 359 logging.basicConfig( |
317 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 360 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
318 min(sys.argv.count('-v'), 3)], | 361 min(sys.argv.count('-v'), 3)], |
319 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 362 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
320 '%(lineno)d) %(message)s') | 363 '%(lineno)d) %(message)s') |
321 unittest.main() | 364 unittest.main() |
OLD | NEW |