Skip to content

Commit

Permalink
linter: allow absent output counts in case of expected test failure
Browse files Browse the repository at this point in the history
otherwise we contradict that failing tests must nut have outputs

fixes: #16235
  • Loading branch information
bernt-matthias committed Jun 12, 2023
1 parent 84d2ba8 commit 54e54bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/galaxy/tool_util/linters/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def lint_tests(tool_xml, lint_ctx):
_check_asserts(test_idx, test.findall(".//assert_contents"), lint_ctx)

# check if expect_num_outputs is set if there are outputs with filters
# (except for tests with expect_failure .. which can't have test outputs)
filter = tool_xml.findall("./outputs//filter")
if len(filter) > 0 and "expect_num_outputs" not in test.attrib:
lint_ctx.warn("Test should specify 'expect_num_outputs' if outputs have filters", node=test)
if not asbool(test.attrib.get("expect_failure", False)):
lint_ctx.warn("Test should specify 'expect_num_outputs' if outputs have filters", node=test)

# really simple test that test parameters are also present in the inputs
for param in test.findall("param"):
Expand Down Expand Up @@ -145,7 +147,7 @@ def lint_tests(tool_xml, lint_ctx):
node=output,
)

if "expect_failure" in test.attrib and asbool(test.attrib["expect_failure"]):
if asbool(test.attrib.get("expect_failure", False)):
if found_output_test:
lint_ctx.error(f"Test {test_idx}: Cannot specify outputs in a test expecting failure.", node=test)
continue
Expand Down
6 changes: 5 additions & 1 deletion test/unit/tool_util/test_tool_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@
<output name="data_name"/>
<output_collection name="collection_name"/>
</test>
<!-- no count or discovered_dataset/element
- no outputs can be given
- consequently also counts and expect_num_output need not to be given -->
<test expect_failure="true"/>
<!-- no nested element and count at element -->
<test>
<output name="data_name" count="1"/>
Expand Down Expand Up @@ -1687,7 +1691,7 @@ def test_tests_discover_outputs(lint_ctx):
in lint_ctx.error_messages
)
assert (
"Test 4: test collection 'collection_name' must contain nested 'element' tags and/or element childen with a 'count' attribute"
"Test 5: test collection 'collection_name' must contain nested 'element' tags and/or element childen with a 'count' attribute"
in lint_ctx.error_messages
)
assert not lint_ctx.warn_messages
Expand Down

0 comments on commit 54e54bb

Please sign in to comment.