Skip to content

Commit

Permalink
Add a test flag to force tests not to skip on required tools.
Browse files Browse the repository at this point in the history
I will occasionally see tests that skip instead of failing because the tool required to run the test stopped loading - maybe a parsing error or a misconfiguration around sample data tables. I don't think this should be the default but we should make sure all our CI tests are running properly.
  • Loading branch information
jmchilton committed Oct 14, 2024
1 parent 687f366 commit 2509234
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy_test/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from galaxy_test.base.env import setup_keep_outdir
from galaxy_test.base.populators import (
_raise_skip_if,
check_missing_tool,
DatasetCollectionPopulator,
DatasetPopulator,
get_tool_ids,
Expand Down Expand Up @@ -148,7 +148,7 @@ def check_required_tools(anonymous_galaxy_interactor, request):
for marker in request.node.iter_markers():
if marker.name == "requires_tool_id":
tool_id = marker.args[0]
_raise_skip_if(tool_id not in get_tool_ids(anonymous_galaxy_interactor))
check_missing_tool(tool_id not in get_tool_ids(anonymous_galaxy_interactor))


@pytest.fixture
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy_test/base/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
Tuple,
)

from galaxy.util import asbool

DEFAULT_WEB_HOST = socket.gethostbyname("localhost")
REQUIRE_ALL_NEEDED_TOOLS = asbool(os.environ.get("GALAXY_TEST_REQUIRE_ALL_NEEDED_TOOLS", "0"))

GalaxyTarget = Tuple[str, Optional[str], str]

Expand Down
13 changes: 12 additions & 1 deletion lib/galaxy_test/base/populators.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
HasAnonymousGalaxyInteractor,
)
from .api_util import random_name
from .env import REQUIRE_ALL_NEEDED_TOOLS

FILE_URL = "https://raw.githubusercontent.com/galaxyproject/galaxy/dev/test-data/4.bed"
FILE_MD5 = "37b59762b59fff860460522d271bc111"
Expand Down Expand Up @@ -180,7 +181,7 @@ def method_wrapper(method):

@wraps(method)
def wrapped_method(api_test_case, *args, **kwargs):
_raise_skip_if(tool_id not in get_tool_ids(api_test_case.anonymous_galaxy_interactor))
check_missing_tool(tool_id not in get_tool_ids(api_test_case.anonymous_galaxy_interactor))
return method(api_test_case, *args, **kwargs)

return wrapped_method
Expand Down Expand Up @@ -268,6 +269,16 @@ def _raise_skip_if(check, *args):
raise unittest.SkipTest(*args)


def check_missing_tool(check):
if check:
if REQUIRE_ALL_NEEDED_TOOLS:
raise AssertionError("Test requires a missing tool and GALAXY_TEST_REQUIRE_ALL_NEEDED_TOOLS is enabled")
else:
raise unittest.SkipTest(
"Missing tool required to run test, skipping. If this is not intended, ensure GALAXY_TEST_TOOL_CONF if set contains the required tool_conf.xml target and the tool properly parses and loads in Galaxy's test configuration"
)


def conformance_tests_gen(directory, filename="conformance_tests.yaml"):
conformance_tests_path = os.path.join(directory, filename)
with open(conformance_tests_path) as f:
Expand Down

0 comments on commit 2509234

Please sign in to comment.