Skip to content

Commit

Permalink
messages: enforce unique task messages
Browse files Browse the repository at this point in the history
* Closes #6056
  • Loading branch information
oliver-sanders committed Jul 15, 2024
1 parent dc9f01b commit 6858181
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2434,9 +2434,18 @@ def get_taskdef(
raise WorkflowConfigError(str(exc))
else:
# Record custom message outputs from [runtime].
messages = set(self.cfg['runtime'][name]['outputs'].values())
for output, message in (
self.cfg['runtime'][name]['outputs'].items()
):
try:
messages.remove(message)
except KeyError:
raise WorkflowConfigError(

Check warning on line 2444 in cylc/flow/config.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/config.py#L2443-L2444

Added lines #L2443 - L2444 were not covered by tests
'Duplicate task message in'
f' "[runtime][{name}][outputs]'
f'{output} = {message}" - messages must be unique'
)
valid, msg = TaskOutputValidator.validate(output)
if not valid:
raise WorkflowConfigError(
Expand Down
34 changes: 34 additions & 0 deletions tests/integration/validate/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,37 @@ def test_completion_expression_cylc7_compat(
match="completion cannot be used in Cylc 7 compatibility mode."
):
validate(id_)


def test_unique_messages(
flow,
validate
):
"""Task messages must be unique in the [outputs] section.
See: https://github.com/cylc/cylc-flow/issues/6056
"""
id_ = flow({
'scheduling': {
'graph': {'R1': 'foo'}
},
'runtime': {
'foo': {
'outputs': {
'a': 'foo',
'b': 'bar',
'c': 'baz',
'd': 'foo',
}
},
}
})

with pytest.raises(
WorkflowConfigError,
match=(
r'"\[runtime\]\[foo\]\[outputs\]d = foo"'
' - messages must be unique'
),
):
validate(id_)

0 comments on commit 6858181

Please sign in to comment.