Record bounded wrapped-label trials and independent conservation review
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from pathlib import Path
|
||||
import datetime, hashlib, json, os, subprocess, sys
|
||||
|
||||
assert len(sys.argv) == 2 and sys.argv[1] in ['E', 'F']
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
run = root/('.local/native-wrapped-'+sys.argv[1])
|
||||
record = json.loads((run/'baseline.json').read_text(encoding='utf-8'))
|
||||
assert record['label_profile'] == sys.argv[1]
|
||||
sha = lambda path: hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
for relative, entry in record['files'].items():
|
||||
assert sha(run/relative) == entry['sha256']
|
||||
system = os.environ['SystemRoot']
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = str(Path(system)/'System32')+';'+system
|
||||
for key in list(env):
|
||||
if key.startswith(('CARGO_', 'RUST', 'LLVM', 'WGPU', 'ARCADIA_')):
|
||||
del env[key]
|
||||
env['ARCADIA_LABEL_EXPERIMENT'] = sys.argv[1]
|
||||
receipt = {'source': record['source'], 'start': datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||
'label_profile': sys.argv[1], 'binary_sha256': record['files']['bin/arcadia-studio.exe']['sha256'],
|
||||
'runtime_sha256': record['files']['bin/libunwind.dll']['sha256'],
|
||||
'fixture_sha256': record['files']['working/eight-card.json']['sha256'],
|
||||
'cwd': str(run/'working'), 'path': env['PATH']}
|
||||
with (run/'stdout.log').open('xb') as out, (run/'stderr.log').open('xb') as err:
|
||||
child = subprocess.Popen([str(run/'bin/arcadia-studio.exe')], cwd=run/'working', env=env,
|
||||
stdout=out, stderr=err, creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
receipt['pid'] = child.pid
|
||||
(run/'started.json').write_text(json.dumps(receipt, indent=2)+'\n', encoding='utf-8')
|
||||
print(json.dumps(receipt, indent=2), flush=True)
|
||||
code = child.wait()
|
||||
receipt.update({'exit_code': code, 'finished': datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||
'stdout_bytes': (run/'stdout.log').stat().st_size, 'stderr_bytes': (run/'stderr.log').stat().st_size,
|
||||
'all_pinned_files_unchanged': all(sha(run/r)==v['sha256'] for r,v in record['files'].items())})
|
||||
(run/'finished.json').write_text(json.dumps(receipt, indent=2)+'\n', encoding='utf-8')
|
||||
print(json.dumps(receipt, indent=2), flush=True)
|
||||
assert code == 0 and receipt['stdout_bytes'] == receipt['stderr_bytes'] == 0 and receipt['all_pinned_files_unchanged']
|
||||
Reference in New Issue
Block a user