diff --git a/package.xml b/package.xml index 3783ec4..723cb66 100644 --- a/package.xml +++ b/package.xml @@ -40,6 +40,7 @@ Copyright (c) 2023-2026 Robotics and AI Institute LLC dba RAI Institute. All rig python3-prompt-toolkit python3-pytest python3-pytest-cov + python3-pytest-timeout ament_cmake diff --git a/pyproject.toml b/pyproject.toml index 4ba4fe7..1176b19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,9 @@ target-version = ["py310"] [tool.isort] profile = "black" line_length = 120 + +[tool.pytest.ini_options] +# Consider any test running longer than 4 minutes hung +timeout = 240 +# Use "thread" in case we encounter a hang in ROS extension +timeout_method = "thread" diff --git a/test/system/conftest.py b/test/system/conftest.py index e605beb..4013f9f 100644 --- a/test/system/conftest.py +++ b/test/system/conftest.py @@ -113,3 +113,16 @@ def hardware_spot_graph_description( def pytest_configure() -> None: pytest.hardware_spot_graph_description = hardware_spot_graph_description + + +def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: + """Exempt the system tests from the global pytest-timeout limit. + + These tests drive real hardware and block on interactive prompts, so wall + clock time is not a meaningful signal of a hang the way it is for the unit + tests. + """ + system_test_dir = str(pathlib.Path(__file__).parent) + for item in items: + if str(item.fspath).startswith(system_test_dir): + item.add_marker(pytest.mark.timeout(0))