Commit 54e54bbf authored by Matthias Bernt's avatar Matthias Bernt
Browse files

linter: allow absent output counts in case of expected test failure

otherwise we contradict that failing tests must nut have outputs

fixes: https://github.com/galaxyproject/galaxy/issues/16235
parent 84d2ba8e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -60,8 +60,10 @@ 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:
            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
@@ -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
+5 −1
Original line number Diff line number Diff line
@@ -775,6 +775,10 @@ TESTS_DISCOVER_OUTPUTS = """
            <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"/>
@@ -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