48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
|
|
"""V8.17 runner contract: artifacts never hide failures or timeouts."""
|
||
|
|
import importlib.util
|
||
|
|
import json
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
PATH=Path(__file__).resolve().parents[1]/'scripts'/'regression_v817.py'
|
||
|
|
spec=importlib.util.spec_from_file_location('regression_v817',PATH)
|
||
|
|
m=importlib.util.module_from_spec(spec)
|
||
|
|
sys.modules[spec.name]=m
|
||
|
|
spec.loader.exec_module(m)
|
||
|
|
|
||
|
|
|
||
|
|
def test_clean_report(tmp_path):
|
||
|
|
r=m.Run('round1-batch1',['tests/test_example.py'],'PASS',1.25,0,4,str(tmp_path/'e.log'))
|
||
|
|
out=m.write_reports([r],tmp_path/'report',1,1)
|
||
|
|
assert out['status']=='PASS'
|
||
|
|
assert out['tests_last_complete_round']==4
|
||
|
|
assert (tmp_path/'report.html').read_text().startswith('<!doctype html>')
|
||
|
|
|
||
|
|
|
||
|
|
def test_failure_not_erased_by_diagnostic_retry(tmp_path):
|
||
|
|
original=m.Run('round1-batch1',['tests/test_example.py'],'TIMEOUT',1.0,None,0,str(tmp_path/'1.log'))
|
||
|
|
isolated=m.Run('round1-batch1-isolated-1',['tests/test_example.py'],'PASS',1.0,0,2,str(tmp_path/'2.log'))
|
||
|
|
out=m.write_reports([original,isolated],tmp_path/'report',1,1)
|
||
|
|
assert out['status']=='FAIL'
|
||
|
|
assert len(out['failures'])==1
|
||
|
|
assert json.loads((tmp_path/'report.json').read_text())['status']=='FAIL'
|
||
|
|
|
||
|
|
|
||
|
|
def test_runner_rejects_bad_parameters():
|
||
|
|
with pytest.raises(SystemExit) as exc:
|
||
|
|
m.main(['--repeat','0'])
|
||
|
|
assert exc.value.code==2
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.skipif(os.name=='nt',reason='POSIX signal process-group check')
|
||
|
|
def test_slow_pytest_process_times_out_and_is_reaped(tmp_path):
|
||
|
|
test=tmp_path/'test_slow_v817.py'
|
||
|
|
test.write_text('import time\ndef test_slow():\n time.sleep(15)\n')
|
||
|
|
out=m.run_pytest('unit-timeout',[str(test)],1,tmp_path,os.environ.copy())
|
||
|
|
assert out.status=='TIMEOUT'
|
||
|
|
assert out.seconds<7
|
||
|
|
assert 'TIMEOUT' in Path(out.log).read_text()
|