Skip to content

Commit 6845de6

Browse files
committed
refinement of regex
1 parent eade514 commit 6845de6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

cylc/flow/graph_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class GraphParser:
186186

187187
# Match @xtriggers.
188188
REC_XTRIG = re.compile(r'@[\w\-+%]+')
189-
REC_XTRIG_OR = re.compile(r'@.*\s*\|\s*@.*')
189+
REC_XTRIG_OR = re.compile(r'@.*\|.*|.*\|.*@.*')
190190

191191
# Match fully qualified parameterized single nodes.
192192
REC_NODE_FULL = re.compile(

tests/integration/test_config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from cylc.flow.pathutil import get_workflow_run_pub_db_path
3636

3737
Fixture = Any
38+
param = pytest.param
3839

3940

4041
@pytest.mark.parametrize(
@@ -489,9 +490,20 @@ def test_xtrig_signature_validation(
489490
validate(id_)
490491

491492

493+
@pytest.mark.parametrize(
494+
'left',
495+
(
496+
param('@xrandom | @echo', id='xtrig-or-xtrig'),
497+
param('@xrandom | task', id='xtrig-or-task'),
498+
param('task | @echo', id='task-or-xtrig'),
499+
param('@xrandom | foo & bar', id='xtrig-or-complex'),
500+
param('@xrandom & bar | foo', id='complex-or-xtrig'),
501+
)
502+
)
492503
def test_xtrig_or_fails_validation(
493504
flow: "Fixture",
494505
validate: "Fixture",
506+
left: str
495507
):
496508
"""Xtriggers cannot be chained with the 'or'
497509
@@ -506,7 +518,7 @@ def test_xtrig_or_fails_validation(
506518
"xrandom": "xrandom(100)",
507519
"echo": "echo(succeed=True)"
508520
},
509-
"graph": {"R1": "@xrandom | @echo => foo"},
521+
"graph": {"R1": f"{left} => fin"},
510522
}
511523
}
512524
)

0 commit comments

Comments
 (0)