fix(compat): skip writing compat-results.json when no compat tests ran

The pytest_sessionfinish hook in tests/claude_code/conftest.py is loaded
for every pytest run under tests/claude_code/, including sibling unit-
test trees (_driver_unit_tests/, _builder_unit_tests/, ...). Without a
guard, those runs wrote an empty results artifact and silently
overwrote any real artifact from a prior compat-test run.
This commit is contained in:
Cursor Agent 2026-05-06 02:49:53 +00:00 committed by mateo-berri
parent 597d99b026
commit 2073f85eaf

View file

@ -158,7 +158,16 @@ def pytest_sessionstart(session):
def pytest_sessionfinish(session, exitstatus):
"""Write the structured results artifact at end of session."""
"""Write the structured results artifact at end of session.
Skip writing when no compat results were collected this conftest is
loaded by pytest for every test under `tests/claude_code/`, including
sibling unit-test trees (e.g. `_driver_unit_tests/`). Writing an empty
artifact in those runs would silently overwrite a real artifact from a
prior compat-test run on the same checkout.
"""
if not _COLLECTOR.items:
return
artifact_path = os.environ.get(RESULTS_ARTIFACT_ENV) or DEFAULT_ARTIFACT_PATH
payload = {
"schema_version": "1",