mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
gclient_eval: Handle non-string variables.
Bug: 877902 Change-Id: I77a1f213318d1e09ae050c2ea0113b2976bd259e Reviewed-on: https://chromium-review.googlesource.com/1191928 Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user