mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
full test coverage for command linter
- info->warn for deprecated interpreter attribute - add error for empty command text - fix check for TODO in command
This commit is contained in:
@@ -24,7 +24,9 @@ def lint_command(tool_xml, lint_ctx):
|
||||
return
|
||||
|
||||
command = get_command(tool_xml)
|
||||
if "TODO" in command:
|
||||
if command.text is None:
|
||||
lint_ctx.error("Command is empty.", line=root_line, xpath=root_path)
|
||||
elif "TODO" in command.text:
|
||||
lint_ctx.warn("Command template contains TODO text.", line=command.sourceline, xpath=tool_xml.getpath(command))
|
||||
|
||||
command_attrib = command.attrib
|
||||
@@ -41,7 +43,7 @@ def lint_command(tool_xml, lint_ctx):
|
||||
if interpreter_type:
|
||||
interpreter_info = f" with interpreter of type [{interpreter_type}]"
|
||||
if interpreter_type:
|
||||
lint_ctx.info("Command uses deprecated 'interpreter' attribute.", line=command.sourceline, xpath=tool_xml.getpath(command))
|
||||
lint_ctx.warn("Command uses deprecated 'interpreter' attribute.", line=command.sourceline, xpath=tool_xml.getpath(command))
|
||||
lint_ctx.info(f"Tool contains a command{interpreter_info}.", line=command.sourceline, xpath=tool_xml.getpath(command))
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import pytest
|
||||
from galaxy.tool_util.lint import LintContext
|
||||
from galaxy.tool_util.linters import (
|
||||
citations,
|
||||
command,
|
||||
general,
|
||||
help,
|
||||
inputs,
|
||||
@@ -45,6 +46,31 @@ CITATIONS_VALID = """
|
||||
</citations>
|
||||
</tool>
|
||||
"""
|
||||
|
||||
# tests tool xml for command linter
|
||||
COMMAND_MULTIPLE = """
|
||||
<tool>
|
||||
<command/>
|
||||
<command/>
|
||||
</tool>
|
||||
"""
|
||||
COMMAND_MISSING = """
|
||||
<tool/>
|
||||
"""
|
||||
COMMAND_TODO = """
|
||||
<tool>
|
||||
<command>
|
||||
## TODO
|
||||
</command>
|
||||
</tool>
|
||||
"""
|
||||
COMMAND_DETECT_ERRORS_INTERPRETER = """
|
||||
<tool>
|
||||
<command detect_errors="nonsense" interpreter="python"/>
|
||||
</tool>
|
||||
"""
|
||||
|
||||
|
||||
# tests tool xml for general linter
|
||||
GENERAL_MISSING_TOOL_ID_NAME_VERSION = """
|
||||
<tool profile="2109">
|
||||
@@ -513,6 +539,34 @@ TESTS = [
|
||||
'Found 1 likely valid citations.' in x.valid_messages
|
||||
and len(x.info_messages) == 0 and len(x.valid_messages) == 1 and len(x.warn_messages) == 0 and len(x.error_messages) == 0
|
||||
),
|
||||
(
|
||||
COMMAND_MULTIPLE, command.lint_command,
|
||||
lambda x:
|
||||
'More than one command tag found, behavior undefined.' in x.error_messages
|
||||
and len(x.info_messages) == 0 and len(x.valid_messages) == 0 and len(x.warn_messages) == 0 and len(x.error_messages) == 1
|
||||
),
|
||||
(
|
||||
COMMAND_MISSING, command.lint_command,
|
||||
lambda x:
|
||||
'No command tag found, must specify a command template to execute.' in x.error_messages
|
||||
and len(x.info_messages) == 0 and len(x.valid_messages) == 0 and len(x.warn_messages) == 0 and len(x.error_messages) == 1
|
||||
),
|
||||
(
|
||||
COMMAND_TODO, command.lint_command,
|
||||
lambda x:
|
||||
'Tool contains a command.' in x.info_messages
|
||||
and 'Command template contains TODO text.' in x.warn_messages
|
||||
and len(x.info_messages) == 1 and len(x.valid_messages) == 0 and len(x.warn_messages) == 1 and len(x.error_messages) == 0
|
||||
),
|
||||
(
|
||||
COMMAND_DETECT_ERRORS_INTERPRETER, command.lint_command,
|
||||
lambda x:
|
||||
"Command uses deprecated 'interpreter' attribute." in x.warn_messages
|
||||
and 'Tool contains a command with interpreter of type [python].' in x.info_messages
|
||||
and 'Unknown detect_errors attribute [nonsense]' in x.warn_messages
|
||||
and 'Command is empty.' in x.error_messages
|
||||
and len(x.info_messages) == 1 and len(x.valid_messages) == 0 and len(x.warn_messages) == 2 and len(x.error_messages) == 1
|
||||
),
|
||||
(
|
||||
GENERAL_MISSING_TOOL_ID_NAME_VERSION, general.lint_general,
|
||||
lambda x:
|
||||
@@ -794,6 +848,10 @@ TEST_IDS = [
|
||||
'citations: absent',
|
||||
'citations: errors',
|
||||
'citations: valid',
|
||||
'command: multiple',
|
||||
'command: missing',
|
||||
'command: todo',
|
||||
'command: detect_errors and interpreter',
|
||||
'general: missing tool id, name, version; invalid profile',
|
||||
'general: whitespace in version, id, name',
|
||||
'general: requirement without version',
|
||||
|
||||
Reference in New Issue
Block a user