Skip to content

Commit

Permalink
fix regex for profile version
Browse files Browse the repository at this point in the history
- did not allow for new style profile versions (that may have only a
  single digit after the dot)
- fix: do not allow `,` in profile version
  • Loading branch information
bernt-matthias committed Jul 28, 2023
1 parent 3269758 commit 77c0e91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/linters/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ERROR_ID_MSG = "Tool does not define an id attribute."
VALID_ID_MSG = "Tool defines an id [%s]."

PROFILE_PATTERN = re.compile(r"^[1,2]\d\.[0,1]\d$")
PROFILE_PATTERN = re.compile(r"^[12]\d\.(01|05|09|\d)$")
PROFILE_INFO_DEFAULT_MSG = "Tool targets 16.01 Galaxy profile."
PROFILE_INFO_SPECIFIED_MSG = "Tool specifies profile version [%s]."
PROFILE_INVALID_MSG = "Tool specifies an invalid profile version [%s]."
Expand Down
18 changes: 18 additions & 0 deletions test/unit/tool_util/test_tool_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
</tool>
"""

GENERAL_VALID_NEW_PROFILE_FMT = """
<tool name="valid name" id="valid_id" version="1.0+galaxy1" profile="23.0">
</tool>
"""

# test tool xml for help linter
HELP_MULTIPLE = """
<tool>
Expand Down Expand Up @@ -1016,6 +1021,19 @@ def test_general_valid(lint_ctx):
assert not lint_ctx.error_messages


def test_general_valid_new_profile_fmt(lint_ctx):
tool_source = get_xml_tool_source(GENERAL_VALID_NEW_PROFILE_FMT)
run_lint(lint_ctx, general.lint_general, XmlToolSource(tool_source))
assert "Tool defines a version [1.0+galaxy1]." in lint_ctx.valid_messages
assert "Tool specifies profile version [23.0]." in lint_ctx.valid_messages
assert "Tool defines an id [valid_id]." in lint_ctx.valid_messages
assert "Tool defines a name [valid name]." in lint_ctx.valid_messages
assert not lint_ctx.info_messages
assert len(lint_ctx.valid_messages) == 4
assert not lint_ctx.warn_messages
assert not lint_ctx.error_messages


def test_help_multiple(lint_ctx):
tool_source = get_xml_tool_source(HELP_MULTIPLE)
run_lint(lint_ctx, help.lint_help, tool_source)
Expand Down

0 comments on commit 77c0e91

Please sign in to comment.