Datasets:
Formats:
csv
Languages:
English
Size:
1K - 10K
Tags:
mathematics
inverse-problems
observability
noncommutative-algebra
symbolic-computation
calibration-rigidity
File size: 2,768 Bytes
d1c6c9a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/usr/bin/env python3
"""Execute the real test suite and record outcomes, versions, and source hashes."""
from __future__ import annotations
import hashlib
import importlib.metadata
import json
import platform
import subprocess
import sys
import time
import xml.etree.ElementTree as ET
from datetime import datetime, timezone
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
def main() -> int:
dest=ROOT/'validation'; dest.mkdir(exist_ok=True)
started=time.perf_counter()
command=[sys.executable,'-m','pytest','-q','--junitxml=validation/pytest.xml']
result=subprocess.run(command,cwd=ROOT,text=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
elapsed=time.perf_counter()-started
(dest/'pytest_output.txt').write_text(result.stdout,encoding='utf-8')
print(result.stdout,end='')
counts=dict(tests=0,failures=0,errors=0,skipped=0)
xml=dest/'pytest.xml'
if xml.exists():
for suite in ET.parse(xml).getroot().iter('testsuite'):
for name in counts:
counts[name]+=int(suite.attrib.get(name,0))
versions={'python':platform.python_version(),'platform':platform.platform()}
for name in ['sympy','numpy','matplotlib','mpmath','pytest','nbformat','nbclient','ipykernel']:
try: versions[name]=importlib.metadata.version(name)
except importlib.metadata.PackageNotFoundError: versions[name]='not installed'
source_paths=sorted(set(ROOT.glob('src/**/*.py'))|set(ROOT.glob('tests/*.py'))|set(ROOT.glob('scripts/*.py'))|
set(ROOT.glob('manuscript/sections/*.tex'))|{ROOT/'manuscript/main.tex',ROOT/'manuscript/references.bib'})
hashes={str(p.relative_to(ROOT)):hashlib.sha256(p.read_bytes()).hexdigest() for p in source_paths}
passed=counts['tests']-counts['failures']-counts['errors']-counts['skipped']
report={'run_utc':datetime.now(timezone.utc).isoformat(),'command':command,'exit_code':result.returncode,
'counts':counts,'passed':passed,'elapsed_seconds':round(elapsed,3),'versions':versions,
'source_sha256':hashes,
'scope':'Finite executable checks, not independent peer review or proof-assistant certification.'}
(dest/'validation_report.json').write_text(json.dumps(report,indent=2)+'\n',encoding='utf-8')
if result.returncode==0 and counts['tests']>0 and counts['failures']==counts['errors']==0:
(ROOT/'manuscript/validation_summary.tex').write_text(
f'\\newcommand{{\\TestCount}}{{{passed}}}\n\\newcommand{{\\TestRuntime}}{{{elapsed:.2f}}}\n')
else:
print('Validation failed; manuscript success counts were not updated.',file=sys.stderr)
return result.returncode or 1
return 0
if __name__=='__main__':
raise SystemExit(main())
|