diff --git a/tests/ci_runnable.py b/tests/ci_runnable.py index 2a3362c62..8c9b6aa48 100644 --- a/tests/ci_runnable.py +++ b/tests/ci_runnable.py @@ -6,7 +6,8 @@ `AgentStart`) or calls a host that can be reached and is not local, when the baseline does not name it; and a baseline entry that no longer is one. The test's own body is read, and so are the non-test functions of its module that it names as a fixture or calls, transitively; a cause in -another module is not seen. The walk, the baseline format and the report are `wide_scans`'s. +another module is not seen. A module whose text does not contain `integration` is not parsed. +The walk, the baseline format and the report are `wide_scans`'s. """ from __future__ import annotations @@ -157,6 +158,11 @@ def _reached(test: Function, tree: ast.Module) -> list[ast.AST]: def _violators(text: str, required_fields: Mapping[str, frozenset[str]]) -> dict[str, str]: + # A module that does not name the selector has no test the guard checks, and skipping it + # keeps the walk of the whole tree inside the time limit, as `SCAN_TEXT` does for the + # wide-scans guard. + if "integration" not in text: + return {} tree = ast.parse(text) found: dict[str, str] = {} for test, marked in walk_tests(tree, _marks_integration): diff --git a/tests/drift/test_no_thread_pool.py b/tests/drift/test_no_thread_pool.py index 7e299902e..d3abc1e73 100644 --- a/tests/drift/test_no_thread_pool.py +++ b/tests/drift/test_no_thread_pool.py @@ -13,6 +13,7 @@ import pytest +from tests.time_limit import LOADED_TEST_TIME_LIMIT from tests.tracked_files import ROOT, guarded_files PIPELINE_CLI = ROOT / "src/agent_build_kit/cli/pipeline.py" @@ -40,6 +41,7 @@ def names_in(path: Path) -> list[str]: return found +@pytest.mark.time_limit(LOADED_TEST_TIME_LIMIT) @pytest.mark.integration def test_no_source_file_defines_or_uses_a_pass_rule_or_the_loaded_tick_marker() -> None: sources = guarded_files(under=["src"], suffixes={".py"}) diff --git a/tests/test_ci_runnable_guard.py b/tests/test_ci_runnable_guard.py index 7a15b333a..648e5cadb 100644 --- a/tests/test_ci_runnable_guard.py +++ b/tests/test_ci_runnable_guard.py @@ -13,6 +13,7 @@ import pytest from tests.ci_runnable import check_tests, load_baseline, required_settings_fields +from tests.time_limit import LOADED_TEST_TIME_LIMIT NONE: frozenset[str] = frozenset() REQUIRED = {"Settings": frozenset({"api_token"})} @@ -168,6 +169,7 @@ def test_a_baseline_entry_that_is_no_longer_a_violator_is_reported_as_stale( assert "stale" in problems[0] +@pytest.mark.time_limit(LOADED_TEST_TIME_LIMIT) @pytest.mark.integration def test_no_integration_test_of_the_kit_needs_more_than_ci_has() -> None: problems = check_tests(baseline=load_baseline(), required_fields=required_settings_fields()) diff --git a/tests/test_live_tag_drift.py b/tests/test_live_tag_drift.py index 4a9b8c46c..fef010cb9 100644 --- a/tests/test_live_tag_drift.py +++ b/tests/test_live_tag_drift.py @@ -13,6 +13,7 @@ from tests.live_tag_drift import INTEGRATION, find_live_modules from tests.runtime_tag_collection import ROOT +from tests.time_limit import LOADED_TEST_TIME_LIMIT # One module per way a test is marked `e2e`. MARKS = { @@ -87,6 +88,7 @@ def test_a_file_listed_and_gone_before_it_is_read_is_skipped(tmp_path: Path) -> assert find_live_modules(tmp_path / "tests") == [live] +@pytest.mark.time_limit(LOADED_TEST_TIME_LIMIT) @pytest.mark.integration def test_every_module_the_old_glob_and_text_match_found_is_still_found() -> None: old = [ diff --git a/tests/test_secret_leak_guards.py b/tests/test_secret_leak_guards.py index 72b31409b..81ea5ec0f 100644 --- a/tests/test_secret_leak_guards.py +++ b/tests/test_secret_leak_guards.py @@ -21,6 +21,7 @@ from agent_build_kit import settings as settings_module from agent_build_kit.settings import Settings +from tests.time_limit import LOADED_TEST_TIME_LIMIT TESTS = Path(__file__).parent SAMPLE = "sample-env-value-0001" @@ -55,6 +56,7 @@ def _prints_its_environment(model: str) -> bool: return SAMPLE in repr(cast(Any, cls).model_construct(**{field: {"KEY": SAMPLE}})) +@pytest.mark.time_limit(LOADED_TEST_TIME_LIMIT) @pytest.mark.integration def test_no_test_support_model_prints_its_environment() -> None: """The models are found when the test runs, not when the module is imported.""" diff --git a/tests/test_wide_scans_are_integration.py b/tests/test_wide_scans_are_integration.py index 296efe6a5..d5de31695 100644 --- a/tests/test_wide_scans_are_integration.py +++ b/tests/test_wide_scans_are_integration.py @@ -184,6 +184,7 @@ def test_the_default_run_still_collects_the_logic_tests_of_a_check( assert default_run_collects(pytester, module) +@pytest.mark.time_limit(LOADED_TEST_TIME_LIMIT) @pytest.mark.integration def test_no_test_of_the_repository_scans_it_without_the_integration_selector() -> None: assert check_tests(TESTS_ROOT, baseline=load_baseline()) == []