Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: tests/gclient_test.py

Issue 23875029: Handle conflicting os deps better in gclient. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Now with unittests. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gclient.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 self.assertEquals( 468 self.assertEquals(
469 [ 469 [
470 'svn://example.com/bar', 470 'svn://example.com/bar',
471 'svn://example.com/bar/unix', 471 'svn://example.com/bar/unix',
472 'svn://example.com/foo', 472 'svn://example.com/foo',
473 'svn://example.com/foo/baz', 473 'svn://example.com/foo/baz',
474 'svn://example.com/foo/unix', 474 'svn://example.com/foo/unix',
475 ], 475 ],
476 sorted(self._get_processed())) 476 sorted(self._get_processed()))
477 477
478 def testUpdateWithOsDeps(self):
479 """Verifies that complicated deps_os constructs result in the
480 correct data also with multple operating systems. Also see
481 testDepsOsOverrideDepsInDepsFile."""
482
483 test_data = [
484 # Tuples of deps, deps_os, os_list and expected_deps.
485 (
486 # OS doesn't need module.
487 {'foo': 'default_foo'},
488 {'os1': { 'foo': None } },
489 ['os1'],
490 {'foo': None}
491 ),
492 (
493 # OS wants a different version of module.
494 {'foo': 'default_foo'},
495 {'os1': { 'foo': 'os1_foo'} },
496 ['os1'],
497 {'foo': 'os1_foo'}
498 ),
499 (
500 # OS with no overrides at all.
501 {'foo': 'default_foo'},
502 {'os1': { 'foo': None } },
503 ['os2'],
504 {'foo': 'default_foo'}
505 ),
506 (
507 # One OS doesn't need module, one OS wants the default.
508 {'foo': 'default_foo'},
509 {'os1': { 'foo': None },
510 'os2': {}},
511 ['os1', 'os2'],
512 {'foo': 'default_foo'}
513 ),
514 (
515 # One OS doesn't need module, another OS wants a special version.
516 {'foo': 'default_foo'},
517 {'os1': { 'foo': None },
518 'os2': { 'foo': 'os2_foo'}},
519 ['os1', 'os2'],
520 {'foo': 'os2_foo'}
521 ),
522 (
523 # One OS wants to add a module.
524 {'foo': 'default_foo'},
525 {'os1': { 'bar': 'os1_bar' }},
526 ['os1'],
527 {'foo': 'default_foo',
528 'bar': 'os1_bar'}
529 ),
530 (
531 # One OS wants to add a module. One doesn't care.
532 {'foo': 'default_foo'},
533 {'os1': { 'bar': 'os1_bar' }},
534 ['os1', 'os2'],
535 {'foo': 'default_foo',
536 'bar': 'os1_bar'}
537 ),
538 (
539 # Two OSes want to add a module with the same definition.
540 {'foo': 'default_foo'},
541 {'os1': { 'bar': 'os1_bar' }},
M-A Ruel 2013/12/13 15:33:36 I think you meant: {'os1': { 'bar': 'os1_bar' }, '
542 ['os1', 'os2'],
543 {'foo': 'default_foo',
544 'bar': 'os1_bar'}
545 ),
546 ]
547 for deps, deps_os, target_os_list, expected_deps in test_data:
548 gclient.Dependency.UpdateWithOsDeps(deps, deps_os, target_os_list)
549 self.assertEqual(deps, expected_deps)
550
478 def testDepsOsOverrideDepsInDepsFile(self): 551 def testDepsOsOverrideDepsInDepsFile(self):
479 """Verifies that a 'deps_os' path can override a 'deps' path. 552 """Verifies that a 'deps_os' path can override a 'deps' path. Also
553 see testUpdateWithOsDeps above.
480 """ 554 """
481 555
482 write( 556 write(
483 '.gclient', 557 '.gclient',
484 'solutions = [\n' 558 'solutions = [\n'
485 ' { "name": "foo",\n' 559 ' { "name": "foo",\n'
486 ' "url": "svn://example.com/foo",\n' 560 ' "url": "svn://example.com/foo",\n'
487 ' },]\n') 561 ' },]\n')
488 write( 562 write(
489 os.path.join('foo', 'DEPS'), 563 os.path.join('foo', 'DEPS'),
490 'target_os = ["baz"]\n' 564 'target_os = ["baz"]\n'
491 'deps = {\n' 565 'deps = {\n'
492 ' "foo/src": "/src",\n' # This path is to be overridden by similar path 566 ' "foo/src": "/src",\n' # This path is to be overridden by similar path
493 # in deps_os['unix']. 567 # in deps_os['unix'].
494 '}\n' 568 '}\n'
495 'deps_os = {\n' 569 'deps_os = {\n'
496 ' "unix": { "foo/unix": "/unix",' 570 ' "unix": { "foo/unix": "/unix",'
497 ' "foo/src": "/src_unix"},\n' 571 ' "foo/src": "/src_unix"},\n'
498 ' "baz": { "foo/baz": "/baz", },\n' 572 ' "baz": { "foo/baz": "/baz",\n'
573 ' "foo/src": None},\n'
499 ' "jaz": { "foo/jaz": "/jaz", },\n' 574 ' "jaz": { "foo/jaz": "/jaz", },\n'
500 '}') 575 '}')
501 576
502 parser = gclient.OptionParser() 577 parser = gclient.OptionParser()
503 options, _ = parser.parse_args(['--jobs', '1']) 578 options, _ = parser.parse_args(['--jobs', '1'])
504 options.deps_os = 'unix' 579 options.deps_os = 'unix'
505 580
506 obj = gclient.GClient.LoadCurrentConfig(options) 581 obj = gclient.GClient.LoadCurrentConfig(options)
507 obj.RunOnDeps('None', []) 582 obj.RunOnDeps('None', [])
508 self.assertEqual(['unix'], sorted(obj.enforced_os)) 583 self.assertEqual(['unix'], sorted(obj.enforced_os))
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) 645 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
571 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) 646 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True)
572 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) 647 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr)
573 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) 648 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True)
574 logging.basicConfig( 649 logging.basicConfig(
575 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 650 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
576 min(sys.argv.count('-v'), 3)], 651 min(sys.argv.count('-v'), 3)],
577 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' 652 format='%(relativeCreated)4d %(levelname)5s %(module)13s('
578 '%(lineno)d) %(message)s') 653 '%(lineno)d) %(message)s')
579 unittest.main() 654 unittest.main()
OLDNEW
« no previous file with comments | « gclient.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698