51 lines
3.6 KiB
Python
51 lines
3.6 KiB
Python
"""One root-authorized immutable Windows test run; no build or UI automation."""
|
|
import datetime
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import re
|
|
import subprocess
|
|
import time
|
|
|
|
root = Path.cwd()
|
|
stage = root / '.local/contextual-source-layout-20260911/tests-final'
|
|
output = root / '.local/contextual-source-layout-20260911/full-679'
|
|
assert not output.exists(), 'Refuse to overwrite a full-run record'
|
|
output.mkdir()
|
|
binary = stage / 'arcadia-studio-tests.exe'
|
|
expected = '75AB0E151D85473631D5A145527F3F6B9768A3CD61CE66A0603A574E09557017'
|
|
digest = lambda p: hashlib.sha256(p.read_bytes()).hexdigest().upper()
|
|
assert digest(binary) == expected, 'Wrong immutable executable'
|
|
assert digest(stage / 'libunwind.dll') == 'F45604A12E8BCD839FD86F667C1BE1CC7C4F9DA2B3C69FF381AC708F0E1AE7D4'
|
|
env = dict(os.environ)
|
|
system_root = next(v for k, v in env.items() if k.upper() == 'SYSTEMROOT')
|
|
for key in list(env):
|
|
if key.upper() in ('RUST_MIN_STACK', 'APPDATA', 'LOCALAPPDATA', 'TEMP', 'TMP', 'PATH'):
|
|
del env[key]
|
|
for key, relative in [('APPDATA', 'profile/roaming'), ('LOCALAPPDATA', 'profile/local'), ('TEMP', 'temp'), ('TMP', 'temp')]:
|
|
path = output / relative
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
env[key] = str(path)
|
|
env['PATH'] = str(stage) + ';' + system_root + '\\System32;' + system_root
|
|
inventory = subprocess.run([str(binary), '--list'], cwd=root, env=env, capture_output=True)
|
|
(output / 'inventory.stdout.log').write_bytes(inventory.stdout)
|
|
(output / 'inventory.stderr.log').write_bytes(inventory.stderr)
|
|
names = [line for line in inventory.stdout.decode('utf-8').splitlines() if line.endswith(': test')]
|
|
admission = {'checkedUtc': datetime.datetime.now(datetime.timezone.utc).isoformat(), 'executable': str(binary), 'sha256': digest(binary), 'bytes': binary.stat().st_size, 'runtimeSha256': digest(stage / 'libunwind.dll'), 'inventoryExitCode': inventory.returncode, 'tests': len(names), 'uniqueTests': len(set(names)), 'threadStack': 'ordinary Windows/Rust defaults; no RUST_MIN_STACK override', 'testThreads': 1, 'profileAndTemp': str(output), 'scope': 'Immutable full desktop tests only; no native or Linux acceptance'}
|
|
(output / 'admission.json').write_text(json.dumps(admission, indent=2) + '\n', encoding='utf-8')
|
|
assert inventory.returncode == 0 and len(names) == len(set(names)) == 679, 'Inventory mismatch; full run refused'
|
|
started = datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
print(json.dumps({'state': 'admitted', 'tests': 679, 'sha256': expected, 'started': started}), flush=True)
|
|
tick = time.monotonic()
|
|
with (output / 'full.stdout.log').open('xb') as stdout, (output / 'full.stderr.log').open('xb') as stderr:
|
|
result = subprocess.run([str(binary), '--test-threads=1'], cwd=root, env=env, stdout=stdout, stderr=stderr)
|
|
text = (output / 'full.stdout.log').read_text(encoding='utf-8')
|
|
summary = re.search(r'test result: (\w+)\. (\d+) passed; (\d+) failed; (\d+) ignored; (\d+) measured; (\d+) filtered out; finished in ([\d.]+)s', text)
|
|
record = {'command': [str(binary), '--test-threads=1'], 'started': started, 'finished': datetime.datetime.now(datetime.timezone.utc).isoformat(), 'seconds': time.monotonic() - tick, 'exitCode': result.returncode, 'executableSha256': digest(binary), 'inputIdentityUnchanged': digest(binary) == expected, 'summary': summary.group(0) if summary else None}
|
|
if summary:
|
|
record.update(dict(zip(['passed', 'failed', 'ignored', 'measured', 'filtered'], map(int, summary.groups()[1:6]))))
|
|
(output / 'full-result.json').write_text(json.dumps(record, indent=2) + '\n', encoding='utf-8')
|
|
print(json.dumps(record), flush=True)
|
|
raise SystemExit(result.returncode)
|