Skip to content

Commit

Permalink
gclient: Fix for extra custom_deps.
Browse files Browse the repository at this point in the history
Custom deps not present in DEPS files cause errors when syncing, since
we add them as strings in postprocess_deps, but deps_to_objects expects
a dictionary.

TBR=agable@chromium.org

Bug: 839925
Change-Id: Ic08a83e8692f1bf90d4456c72fe99493363ba747
Reviewed-on: https://chromium-review.googlesource.com/1063326
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
  • Loading branch information
Edward Lemur authored and Commit Bot committed May 17, 2018
1 parent ed1bb34 commit 23a3587
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
6 changes: 3 additions & 3 deletions gclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ def _postprocess_deps(self, deps, rel_prefix):

# If a line is in custom_deps, but not in the solution, we want to append
# this line to the solution.
for d in self.custom_deps:
if d not in deps:
deps[d] = self.custom_deps[d]
for dep_name, dep_info in self.custom_deps.iteritems():
if dep_name not in deps:
deps[dep_name] = {'url': dep_info, 'dep_type': 'git'}

# Make child deps conditional on any parent conditions. This ensures that,
# when flattened, recursed entries have the correct restrictions, even if
Expand Down
2 changes: 1 addition & 1 deletion recipes/trigger_recipe_roller.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Once upon a time, a budding web browser dev team needed a CI system.
All they had was one poor machine under a desk, and its name was Batty,
the Build and Test Yeti.

As the CI needs of the browser grew,
As the CI needs of the browser grew, Batty, the Build and Test Yeti,
53 changes: 48 additions & 5 deletions tests/gclient_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,54 @@ def testTargetOsForHooksInDepsFile(self):
[None, 'checkout_blorp'])

def testOverride(self):
"""Verifies expected behavior of OverrideURL."""
url = "git@github.com:dart-lang/spark.git"
d = gclient.Dependency(None, 'name', url, url,
None, None, None, None, '', True, False, None, True)
self.assertEquals(url, d.url)
"""Verifies expected behavior of URL overrides."""
write(
'.gclient',
'solutions = [\n'
' { "name": "foo",\n'
' "url": "svn://example.com/foo",\n'
' "custom_deps": {\n'
' "foo/bar": "svn://example.com/override",\n'
' "foo/skip2": None,\n'
' "foo/new": "svn://example.com/new",\n'
' },\n'
' },]\n')
write(
os.path.join('foo', 'DEPS'),
'vars = {\n'
' "origin": "svn://example.com",\n'
'}\n'
'deps = {\n'
' "foo/skip": None,\n'
' "foo/bar": "{origin}/bar",\n'
' "foo/baz": "{origin}/baz",\n'
' "foo/skip2": "{origin}/skip2",\n'
' "foo/rel": "/rel",\n'
'}')
parser = gclient.OptionParser()
options, _ = parser.parse_args(['--jobs', '1'])

obj = gclient.GClient.LoadCurrentConfig(options)
obj.RunOnDeps('None', [])

sol = obj.dependencies[0]
self.assertEqual([
('foo', 'svn://example.com/foo'),
('foo/bar', 'svn://example.com/override'),
('foo/baz', 'svn://example.com/baz'),
('foo/new', 'svn://example.com/new'),
('foo/rel', 'svn://example.com/rel'),
], self._get_processed())

self.assertEqual(6, len(sol.dependencies))
self.assertEqual([
('foo/bar', 'svn://example.com/override'),
('foo/baz', 'svn://example.com/baz'),
('foo/new', 'svn://example.com/new'),
('foo/rel', 'svn://example.com/rel'),
('foo/skip', None),
('foo/skip2', None),
], [(dep.name, dep.url) for dep in sol.dependencies])

def testDepsOsOverrideDepsInDepsFile(self):
"""Verifies that a 'deps_os' path cannot override a 'deps' path. Also
Expand Down

0 comments on commit 23a3587

Please sign in to comment.