Commit 4727c647 authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

gclient: Fix getdep and setdep and add tests.

Bug: 843917, 839925
Change-Id: I84e52c95fc91d67375d4d954018f057561896914
Reviewed-on: https://chromium-review.googlesource.com/1064005Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 23a35876
......@@ -2727,9 +2727,8 @@ def CMDgetdep(parser, args):
'DEPS file %s does not exist.' % options.deps_file)
with open(options.deps_file) as f:
contents = f.read()
local_scope = gclient_eval.Parse(
contents, expand_vars=True, validate_syntax=True,
filename=options.deps_file)
local_scope = gclient_eval.Exec(
contents, expand_vars=True, filename=options.deps_file)
for var in options.vars:
print(gclient_eval.GetVar(local_scope, var))
......@@ -2778,9 +2777,8 @@ def CMDsetdep(parser, args):
'DEPS file %s does not exist.' % options.deps_file)
with open(options.deps_file) as f:
contents = f.read()
local_scope = gclient_eval.Parse(
contents, expand_vars=True, validate_syntax=True,
filename=options.deps_file)
local_scope = gclient_eval.Exec(
contents, expand_vars=True, filename=options.deps_file)
for var in options.vars:
name, _, value = var.partition('=')
......
No-op file. Edit this to kick recipes. (Did they do something wrong?)
No-op file. Edit this to kick recipes.
This is a beginning of a story in this silly file.
Once upon a time, a budding web browser dev team needed a CI system.
......
......@@ -823,6 +823,68 @@ class GClientSmokeGIT(GClientSmokeBase):
}]
self.assertEqual(out, output_json)
def testSetDep(self):
fake_deps = os.path.join(self.root_dir, 'DEPS.fake')
with open(fake_deps, 'w') as f:
f.write('\n'.join([
'vars = { ',
' "foo_var": "foo_val",',
' "foo_rev": "foo_rev",',
'}',
'deps = {',
' "foo": {',
' "url": "url@{foo_rev}",',
' },',
' "bar": "url@bar_rev",',
'}',
]))
self.gclient([
'setdep', '-r', 'foo@new_foo', '-r', 'bar@new_bar',
'--var', 'foo_var=new_val', '--deps-file', fake_deps])
with open(fake_deps) as f:
contents = f.read().splitlines()
self.assertEqual([
'vars = { ',
' "foo_var": "new_val",',
' "foo_rev": "new_foo",',
'}',
'deps = {',
' "foo": {',
' "url": "url@{foo_rev}",',
' },',
' "bar": "url@new_bar",',
'}',
], contents)
def testGetDep(self):
fake_deps = os.path.join(self.root_dir, 'DEPS.fake')
with open(fake_deps, 'w') as f:
f.write('\n'.join([
'vars = { ',
' "foo_var": "foo_val",',
' "foo_rev": "foo_rev",',
'}',
'deps = {',
' "foo": {',
' "url": "url@{foo_rev}",',
' },',
' "bar": "url@bar_rev",',
'}',
]))
results = self.gclient([
'getdep', '-r', 'foo', '-r', 'bar','--var', 'foo_var',
'--deps-file', fake_deps])
self.assertEqual([
'foo_val',
'foo_rev',
'bar_rev',
], results[0].splitlines())
def testFlatten(self):
if not self.enabled:
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment