Files
ARCADIA-Studio/harness/experiments/delete-native-f7-20260912/run-probe.py
T

23 lines
1001 B
Python

from pathlib import Path
from datetime import datetime, timezone
import hashlib
import json
import subprocess
import sys
root = Path(__file__).resolve().parent.parent
label, name, *args = sys.argv[1:]
assert label.replace('-', '').isalnum() and name.replace('-', '').isalnum()
folder = root / '.local/native-qa' / label
binary = folder / (label + '.exe')
receipt = folder / (name + '.json')
assert binary.is_file() and not receipt.exists()
command = [str(binary), *args]
run = subprocess.run(command, cwd=root, capture_output=True)
(folder / (name + '.log')).write_bytes(run.stdout + run.stderr)
receipt.write_text(json.dumps({'utc': datetime.now(timezone.utc).isoformat(), 'command': command,
'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'exit': run.returncode}, indent=2) + '\n', encoding='utf-8', newline='\n')
print((run.stdout + run.stderr).decode('utf-8', errors='replace'))
print(json.dumps({'receipt': str(receipt), 'exit': run.returncode}))
sys.exit(run.returncode)