test grouping

This commit is contained in:
Dobromir Popov
2026-07-11 22:11:21 +03:00
parent c195b5ce78
commit 7d259d7c9b
9 changed files with 1424 additions and 19 deletions

View File

@@ -34,6 +34,9 @@ def _make_repo(tmp_path: Path) -> Path:
"import time\n\ndef test_sleeps():\n time.sleep(30)\n"
)
(tests / "test_smoke.py").write_text("def test_smoke():\n assert True\n")
(tests / "test_cache.py").write_text(
'def test_cache_roundtrip():\n """Cache roundtrip remains deterministic."""\n assert True\n'
)
# Real-inference stand-in: must never be collected or run by default.
(tests / "test_real_stub.py").write_text(
"def test_real_inference():\n raise AssertionError('env-gated')\n"
@@ -139,6 +142,12 @@ def test_collection_lists_tests_and_excludes_real_inference(tmp_path, monkeypatc
assert data["enabled"] is True
assert "tests/test_quick.py::test_passes" in data["tests"]
assert "tests/test_slow.py::test_sleeps" in data["tests"]
metadata = {item["id"]: item for item in data["test_metadata"]}
assert metadata["tests/test_cache.py::test_cache_roundtrip"]["description"] == (
"Cache roundtrip remains deterministic."
)
assert "cache" in metadata["tests/test_cache.py::test_cache_roundtrip"]["tags"]
assert any(tag["id"] == "tag:cache" for tag in data["tags"])
assert not any("test_real_" in node_id for node_id in data["tests"])
assert data["collected_at"] is not None
suite_ids = [suite["id"] for suite in data["suites"]]
@@ -190,6 +199,31 @@ def test_run_approved_suite_without_prior_collection(tmp_path):
tracker.stop()
def test_run_all_and_tag_targets(tmp_path):
tracker, port, admin, _user = _start_tracker(tmp_path)
try:
assert _request(port, "GET", "/v1/tests", token=admin)[0] == 200
runner = tracker._test_runner
assert runner is not None
all_state = runner.start("suite:all")
assert all_state["run"]["target"] == "suite:all"
assert len(all_state["run"]["args"]) == len(runner._collected)
finally:
tracker.stop()
second_repo = tmp_path / "second"
second_repo.mkdir()
tracker, _port, _admin, _user = _start_tracker(second_repo)
try:
runner = tracker._test_runner
assert runner is not None
runner.collect()
tagged = runner.start("tag:cache")
assert tagged["run"]["args"] == ["tests/test_cache.py::test_cache_roundtrip"]
finally:
tracker.stop()
@pytest.mark.parametrize("target", [
"",
"-x",