From cbd10c098633458abcd0ba9c46f9df2712992ad3 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 21 Mar 2022 13:33:08 +0100 Subject: [PATCH] linter: allow setting output format with actions --- lib/galaxy/tool_util/linters/outputs.py | 2 ++ test/unit/tool_util/test_tool_linters.py | 28 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/galaxy/tool_util/linters/outputs.py b/lib/galaxy/tool_util/linters/outputs.py index 2e8cd878e1a..f537f342043 100644 --- a/lib/galaxy/tool_util/linters/outputs.py +++ b/lib/galaxy/tool_util/linters/outputs.py @@ -63,6 +63,8 @@ def __check_format(node, lint_ctx, allow_ext=False): lint_ctx.warn(f"Tool {node.tag} output '{node.attrib.get('name', 'with missing name')}' should use either format_source or format/ext", node=node) if "format_source" in node.attrib: return True + if node.find(".//action[@type='format']") is not None: + return True # if allowed (e.g. for discover_datasets), ext takes precedence over format fmt = None if allow_ext: diff --git a/test/unit/tool_util/test_tool_linters.py b/test/unit/tool_util/test_tool_linters.py index e9ddcd1d4a5..bc6aeea0a42 100644 --- a/test/unit/tool_util/test_tool_linters.py +++ b/test/unit/tool_util/test_tool_linters.py @@ -442,6 +442,25 @@ OUTPUTS_COLLECTION_FORMAT_SOURCE = """ """ +# check that setting format with actions is supported +OUTPUTS_FORMAT_ACTION = """ + + + + + + + + + + + + + + +""" + # check that linter does not complain about missing format if from_tool_provided_metadata is used OUTPUTS_DISCOVER_TOOL_PROVIDED_METADATA = """ @@ -1102,6 +1121,15 @@ def test_outputs_collection_format_source(lint_ctx): assert not lint_ctx.error_messages +def test_outputs_format_action(lint_ctx): + tool_source = get_xml_tool_source(OUTPUTS_FORMAT_ACTION) + run_lint(lint_ctx, outputs.lint_output, tool_source) + assert len(lint_ctx.info_messages) == 1 + assert not lint_ctx.valid_messages + assert not lint_ctx.warn_messages + assert not lint_ctx.error_messages + + def test_outputs_discover_tool_provided_metadata(lint_ctx): tool_source = get_xml_tool_source(OUTPUTS_DISCOVER_TOOL_PROVIDED_METADATA) run_lint(lint_ctx, outputs.lint_output, tool_source)