Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dashes in context dimension names #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docs/context.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ supported operators consult the following grammar outline::
expression ::= dimension binary_operator values
expression ::= dimension unary_operator
expression ::= 'true' | 'false'
dimension ::= [[:alnum:]]+
dimension ::= [[:alnum:-]]+
binary_operator ::= '==' | '!=' | '<' | '<=' | '>' | '>=' |
'~=' | '~!=' | '~<' | '~<=' | '~>' | '~>='
unary_operator ::= 'is defined' | 'is not defined'
Expand Down
4 changes: 2 additions & 2 deletions fmf/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,15 @@ def _op_core(self, dimension_name, values, comparator):
# Triple expression: dimension operator values
# [^=].* is necessary as .+ matches '= something'
re_expression_triple = re.compile(
r"(\w+)"
r"([\w-]+)"
+ r"\s*("
+ r"|".join(
set(operator_map.keys()) - {"is defined", "is not defined"})
+ r")\s*"
+ r"([^=].*)")
# Double expression: dimension operator
re_expression_double = re.compile(
r"(\w+)" + r"\s*(" + r"|".join(["is defined", "is not defined"]) + r")"
r"([\w-]+)" + r"\s*(" + r"|".join(["is defined", "is not defined"]) + r")"
)

# Simple boolean value
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ def test_split_expression(self):
assert Context.split_expression("dim < value , second") == (
"dim", "<", ["value", "second"])
assert Context.split_expression("true") == (None, True, None)
assert Context.split_expression("provision-method == local") == (
"provision-method", "==", ["local"])
assert Context.split_expression("provision-method is defined") == (
"provision-method", "is defined", None)

def test_parse_rule(self):
""" Rule parsing """
Expand Down
Loading