51 lines
2.6 KiB
Python
51 lines
2.6 KiB
Python
from pathlib import Path
|
|
import datetime, hashlib, json, os, shutil, subprocess, sys
|
|
|
|
assert len(sys.argv) == 2 and sys.argv[1] in ['F', 'Baseline']
|
|
profile = sys.argv[1]
|
|
root = Path(__file__).resolve().parents[1]
|
|
donor = root / '.local/native-wrapped-F'
|
|
run = root / ('.local/native-wrapped-reopen-' + profile)
|
|
assert not run.exists(), 'Never overwrite a previous native run'
|
|
run.mkdir()
|
|
(run / 'bin').mkdir()
|
|
(run / 'working').mkdir()
|
|
(run / 'captures').mkdir()
|
|
sha = lambda p: hashlib.sha256(p.read_bytes()).hexdigest()
|
|
pins = {
|
|
'bin/arcadia-studio.exe': '2b6d76d744d7422fc826f7f7ca0009b296a0efb751fe0b3bbc1516b8a624c201',
|
|
'bin/libunwind.dll': 'f45604a12e8bcd839fd86f667c1be1cc7c4f9da2b3c69ff381ac708f0e1ae7d4',
|
|
'working/moved-F.json': '0ad4015d06cf513cd8f9cfe3a155c07590ba09585002277d6eed7a78dd3b6a57',
|
|
}
|
|
for relative, expected in pins.items():
|
|
source = donor / relative
|
|
assert sha(source) == expected
|
|
shutil.copyfile(source, run / relative)
|
|
assert sha(run / relative) == expected
|
|
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]
|
|
if profile == 'F':
|
|
env['ARCADIA_LABEL_EXPERIMENT'] = 'F'
|
|
receipt = {'source': 'd0896ced75fea73bcda6bd14f259a34503840704',
|
|
'profile': profile, 'start': datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
|
'files': pins, 'cwd': str(run / 'working'), 'path': env['PATH'],
|
|
'external_profile': env.get('ARCADIA_LABEL_EXPERIMENT')}
|
|
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 / p) == h for p, h in pins.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']
|