Commit 77b7687e authored by Dirk Pranke's avatar Dirk Pranke Committed by Commit Bot

gclient conditionals are supposed to allow '!=', but don't currently.

R=smut@chromium.org
TBR=phajdan.jr@chromium.org
BUG=570091

Change-Id: I9e0cce71105e9b819019d64c8857c2e86796a16f
Reviewed-on: https://chromium-review.googlesource.com/704224
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: 's avatarsmut <smut@google.com>
parent a5b7d73e
......@@ -306,6 +306,8 @@ def EvaluateCondition(condition, variables, referenced_variables=None):
if isinstance(node.ops[0], ast.Eq):
return left == right
if isinstance(node.ops[0], ast.NotEq):
return left != right
raise ValueError(
'unexpected operator: %s %s (inside %r)' % (
......
......@@ -142,9 +142,17 @@ class EvaluateConditionTest(unittest.TestCase):
'a or b', {'a': 'b and c', 'b': 'not c', 'c': 'False'}))
def test_string_equality(self):
self.assertTrue(gclient_eval.EvaluateCondition(
'foo == "baz"', {'foo': '"baz"'}))
self.assertFalse(gclient_eval.EvaluateCondition(
'foo == "bar"', {'foo': '"baz"'}))
def test_string_inequality(self):
self.assertTrue(gclient_eval.EvaluateCondition(
'foo != "bar"', {'foo': '"baz"'}))
self.assertFalse(gclient_eval.EvaluateCondition(
'foo != "baz"', {'foo': '"baz"'}))
def test_string_bool(self):
self.assertFalse(gclient_eval.EvaluateCondition(
'false_str_var and true_var',
......
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