diff --git a/lib/galaxy/tool_util/linters/tests.py b/lib/galaxy/tool_util/linters/tests.py
index 68767a92c97..9c6a68084cc 100644
--- a/lib/galaxy/tool_util/linters/tests.py
+++ b/lib/galaxy/tool_util/linters/tests.py
@@ -38,11 +38,16 @@ def lint_tests(tool_xml, lint_ctx):
if len(assertions) == 0:
continue
if len(assertions) > 1:
- lint_ctx.error(f"Test {test_idx}: More than one {ta} found. Only the first is considered.")
+ lint_ctx.error(f"Test {test_idx}: More than one {ta} found. Only the first is considered.", node=test)
has_test = True
_check_asserts(test_idx, assertions, 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
+ 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)
+
# really simple test that test parameters are also present in the inputs
for param in test.findall("param"):
name = param.attrib.get("name", None)
diff --git a/test/unit/tool_util/test_tool_linters.py b/test/unit/tool_util/test_tool_linters.py
index eb2531de8cf..836168da1b5 100644
--- a/test/unit/tool_util/test_tool_linters.py
+++ b/test/unit/tool_util/test_tool_linters.py
@@ -749,6 +749,20 @@ TESTS_DISCOVER_OUTPUTS = """
"""
+TESTS_EXPECT_NUM_OUTPUTS_FILTER = """
+
+
+
+
+
+
+
+
+
+
+
+"""
+
# tool xml for xml_order linter
XML_ORDER = """
@@ -1586,6 +1600,14 @@ def test_tests_discover_outputs(lint_ctx):
assert len(lint_ctx.error_messages) == 4
+def test_tests_expect_num_outputs_filter(lint_ctx):
+ tool_source = get_xml_tool_source(TESTS_EXPECT_NUM_OUTPUTS_FILTER)
+ run_lint(lint_ctx, tests.lint_tsts, tool_source)
+ assert "Test should specify 'expect_num_outputs' if outputs have filters" in lint_ctx.warn_messages
+ assert len(lint_ctx.warn_messages) == 1
+ assert len(lint_ctx.error_messages) == 0
+
+
def test_xml_order(lint_ctx):
tool_source = get_xml_tool_source(XML_ORDER)
run_lint(lint_ctx, xml_order.lint_xml_order, tool_source)