Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/private/pypi/pep508_evaluate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ def _env_expr(left, op, right):
return left in right
elif op == "not in":
return left not in right
elif op == "<":
return left < right
elif op == "<=":
return left <= right
elif op == ">":
return left > right
elif op == ">=":
return left >= right
else:
return fail("TODO: op unsupported: '{}'".format(op))

Expand Down
22 changes: 16 additions & 6 deletions tests/pypi/pep508/evaluate_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,28 @@ def _evaluate_non_version_env_tests(env):

# When
for input, want in {
"{} == 'osx'".format(var_name): True,
"{} != 'osx'".format(var_name): False,
"'osx' == {}".format(var_name): True,
"'osx' != {}".format(var_name): False,
"'x' in {}".format(var_name): True,
"'osx' < {}".format(var_name): False,
"'osx' <= {}".format(var_name): True,
"'osx' == {}".format(var_name): True,
"'osx' >= {}".format(var_name): True,
"'w' not in {}".format(var_name): True,
}.items(): # buildifier: @unsorted-dict-items
"'x' in {}".format(var_name): True,
"{} != 'osx'".format(var_name): False,
"{} < 'osx'".format(var_name): False,
"{} <= 'osx'".format(var_name): True,
"{} == 'osx'".format(var_name): True,
"{} > 'osx'".format(var_name): False,
"{} >= 'osx'".format(var_name): True,
}.items():
got = evaluate(
input,
env = marker_env,
)
env.expect.that_bool(got).equals(want)
env.expect.where(
expr = input,
env = marker_env,
).that_bool(got).equals(want)

# Check that the non-strict eval gives us back the input when no
# env is supplied.
Expand Down