Skip to content

Commit

Permalink
outputs: better validation errors for alt qualifiers in completion exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Apr 23, 2024
1 parent f7d65ff commit 23567bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
is_relative_to,
)
from cylc.flow.print_tree import print_tree
from cylc.flow.task_qualifiers import ALT_QUALIFIERS
from cylc.flow.simulation import configure_sim_modes
from cylc.flow.subprocctx import SubFuncContext
from cylc.flow.task_events_mgr import (
Expand Down Expand Up @@ -1136,6 +1137,15 @@ def _check_completion_expression(self, task_name: str, expr: str) -> None:
' expressions, use "succeeded or failed".'
)

for alt_qualifier, qualifier in ALT_QUALIFIERS.items():
if alt_qualifier in error:
raise WorkflowConfigError(
f'Error in [runtime][{task_name}]completion:'
f'\n {expr}'
f'\nUse "{qualifier}" not "{alt_qualifier}" '
'in completion expressions.'
)

raise WorkflowConfigError(
# NOTE: str(exc) == "name 'x' is not defined" tested in
# tests/integration/test_optional_outputs.py
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/validate/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ def test_messages(messages, valid, flow, validate):
'but required in the completion expression',
id='failed-implicitly-optional-in-graph-required-in-completion',
),
pytest.param(
'foo',
'(succeed and x) or failed',
'Use "succeeded" not "succeed" in completion expressions',
id='alt-qualifier',
),
]
)
def test_completion_expression_invalid(
Expand Down

0 comments on commit 23567bc

Please sign in to comment.