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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 self.assertEquals( | 418 self.assertEquals( |
419 [ | 419 [ |
420 'svn://example.com/bar', | 420 'svn://example.com/bar', |
421 'svn://example.com/bar/unix', | 421 'svn://example.com/bar/unix', |
422 'svn://example.com/foo', | 422 'svn://example.com/foo', |
423 'svn://example.com/foo/baz', | 423 'svn://example.com/foo/baz', |
424 'svn://example.com/foo/unix', | 424 'svn://example.com/foo/unix', |
425 ], | 425 ], |
426 sorted(self._get_processed())) | 426 sorted(self._get_processed())) |
427 | 427 |
| 428 def testDepsOsOverrideDepsInDepsFile(self): |
| 429 """Verifies that a 'deps_os' path can override a 'deps' path. |
| 430 """ |
| 431 |
| 432 write( |
| 433 '.gclient', |
| 434 'solutions = [\n' |
| 435 ' { "name": "foo",\n' |
| 436 ' "url": "svn://example.com/foo",\n' |
| 437 ' },]\n') |
| 438 write( |
| 439 os.path.join('foo', 'DEPS'), |
| 440 'target_os = ["baz"]\n' |
| 441 'deps = {\n' |
| 442 ' "foo/src": "/src",\n' # This path is to be overridden by similar path |
| 443 # in deps_os['unix']. |
| 444 '}\n' |
| 445 'deps_os = {\n' |
| 446 ' "unix": { "foo/unix": "/unix",' |
| 447 ' "foo/src": "/src_unix"},\n' |
| 448 ' "baz": { "foo/baz": "/baz", },\n' |
| 449 ' "jaz": { "foo/jaz": "/jaz", },\n' |
| 450 '}') |
| 451 |
| 452 parser = gclient.Parser() |
| 453 options, _ = parser.parse_args(['--jobs', '1']) |
| 454 options.deps_os = 'unix' |
| 455 |
| 456 obj = gclient.GClient.LoadCurrentConfig(options) |
| 457 obj.RunOnDeps('None', []) |
| 458 self.assertEqual(['unix'], sorted(obj.enforced_os)) |
| 459 self.assertEquals( |
| 460 [ |
| 461 'svn://example.com/foo', |
| 462 'svn://example.com/foo/baz', |
| 463 'svn://example.com/foo/src_unix', |
| 464 'svn://example.com/foo/unix', |
| 465 ], |
| 466 sorted(self._get_processed())) |
| 467 |
428 def testRecursionOverride(self): | 468 def testRecursionOverride(self): |
429 """Verifies gclient respects the recursion var syntax. | 469 """Verifies gclient respects the recursion var syntax. |
430 | 470 |
431 We check several things here: | 471 We check several things here: |
432 - recursion = 3 sets recursion on the foo dep to exactly 3 | 472 - recursion = 3 sets recursion on the foo dep to exactly 3 |
433 (we pull /fizz, but not /fuzz) | 473 (we pull /fizz, but not /fuzz) |
434 - pulling foo/bar at recursion level 1 (in .gclient) is overriden by | 474 - pulling foo/bar at recursion level 1 (in .gclient) is overriden by |
435 a later pull of foo/bar at recursion level 2 (in the dep tree) | 475 a later pull of foo/bar at recursion level 2 (in the dep tree) |
436 """ | 476 """ |
437 write( | 477 write( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 520 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
481 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 521 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
482 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 522 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
483 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 523 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
484 logging.basicConfig( | 524 logging.basicConfig( |
485 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 525 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
486 min(sys.argv.count('-v'), 3)], | 526 min(sys.argv.count('-v'), 3)], |
487 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 527 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
488 '%(lineno)d) %(message)s') | 528 '%(lineno)d) %(message)s') |
489 unittest.main() | 529 unittest.main() |
OLD | NEW |