Commit 5cc2afd9 authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

gclient_eval: Handle non-string variables.

Bug: 877902
Change-Id: I77a1f213318d1e09ae050c2ea0113b2976bd259e
Reviewed-on: https://chromium-review.googlesource.com/1191928Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent f57841b7
......@@ -602,7 +602,9 @@ def RenderDEPSFile(gclient_dict):
def _UpdateAstString(tokens, node, value):
position = node.lineno, node.col_offset
quote_char = tokens[position][1][0]
quote_char = ''
if isinstance(node, ast.Str):
quote_char = tokens[position][1][0]
tokens[position][1] = quote_char + value + quote_char
node.s = value
......
......@@ -325,6 +325,26 @@ class VarTest(unittest.TestCase):
'}',
]))
def test_gets_and_sets_var_non_string(self):
local_scope = gclient_eval.Exec('\n'.join([
'vars = {',
' "foo": True,',
'}',
]))
result = gclient_eval.GetVar(local_scope, 'foo')
self.assertEqual(result, True)
gclient_eval.SetVar(local_scope, 'foo', 'False')
result = gclient_eval.RenderDEPSFile(local_scope)
self.assertEqual(result, '\n'.join([
'vars = {',
' "foo": False,',
'}',
]))
def test_add_preserves_formatting(self):
before = [
'# Copyright stuff',
......
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