import sys,json
from pathlib import Path
sys.path[:0]=['/out/source','/out/source/tests']
import pytest

class Report:
    def __init__(self):self.failed=[];self.passed=[];self.errors=[];self.collected=0
    def pytest_collection_finish(self,session):self.collected=len(session.items)
    def pytest_runtest_logreport(self,report):
        if report.failed:
            (self.failed if report.when=='call' else self.errors).append(report.nodeid)
        elif report.when=='call' and report.passed:self.passed.append(report.nodeid)

report=Report()
names=['fight_r5','fight','fight_crowd_integration','pr13_boundaries','event_cooldown','loitering_settings',
       'multi_roi_contract','multi_roi_control','multi_roi_runtime','secure_bridge']
code=pytest.main(['-q','-p','no:cacheprovider',*[f'/out/source/tests/test_{n}.py' for n in names]],plugins=[report])
Path('/out/download/contract_suite.json').write_text(json.dumps(dict(exit_code=int(code),collected=report.collected,
    passed=len(report.passed),failed=report.failed,errors=report.errors),indent=2))
raise SystemExit(code)
