Helinity's picture
Release v0.1.0: sanitized Python security research benchmark
1340dfb
Raw History Blame Contribute Delete
1.7 kB
"""Run the acceptance commands and preserve their actual outputs and exit codes."""
import json
import subprocess
import sys
from .release import ROOT, HERE
from scripts.generate_dataset import sanitize_log_output
def main():
commands = [
['-m', 'pytest', '-q'],
['-m', 'scripts.generate_dataset', '--check'],
['-m', 'scripts.validate_dataset'],
['-m', 'research.build', '--check'],
['-m', 'research.harden', '--check'],
['-m', 'research.expansion.release', '--check'],
['-m', 'research.check_hf'],
['-m', 'research.evaluate', '--scope', 'official_3c1', '--split', 'test', '--baseline'],
]
results = []
for command in commands:
try:
run = subprocess.run([sys.executable, *command], cwd=ROOT,
capture_output=True, text=True, timeout=240)
result = dict(exit_code=run.returncode, stdout=sanitize_log_output(run.stdout),
stderr=sanitize_log_output(run.stderr))
except subprocess.TimeoutExpired:
result = dict(exit_code=124, stdout='', stderr='Acceptance command exceeded 240 seconds')
results.append(dict(command='python ' + ' '.join(command), **result))
print(results[-1]['command'], 'PASS' if result['exit_code'] == 0 else 'FAIL', flush=True)
(HERE / 'validation-results.json').write_text(json.dumps(results, indent=2, sort_keys=True) + '\n')
if any(result['exit_code'] for result in results):
raise SystemExit('Acceptance checks failed; inspect validation-results.json')
from .report import main as render_report
render_report()
if __name__ == '__main__':
main()