Record exact native deletion evidence and resize constraint experiments
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timezone
|
||||
import hashlib
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
trial = root / '.local/native-qa/delete-20260912'
|
||||
name, work_name, mode, baseline_name, *extra = sys.argv[1:]
|
||||
assert name.replace('-', '').isalnum() and mode in ['same', 'removed']
|
||||
source = (trial / work_name).resolve()
|
||||
baseline = (trial / baseline_name).resolve()
|
||||
assert source.is_relative_to(trial) and baseline.is_relative_to(trial)
|
||||
assert source.is_dir() and baseline.is_dir()
|
||||
dest = trial / 'checkpoints' / name
|
||||
assert not dest.exists()
|
||||
shutil.copytree(source, dest)
|
||||
checker = root / '.local/native-qa/delete-oracle-warning-fix-42511f0/delete-oracle-warning-fix-42511f0.exe'
|
||||
command = [str(checker), mode, str(baseline / 'project.arcadia'), str(dest / 'project.arcadia'), *extra]
|
||||
run = subprocess.run(command, cwd=root, capture_output=True)
|
||||
files = []
|
||||
for file in sorted(dest.rglob('*')):
|
||||
if file.is_file():
|
||||
raw = file.read_bytes()
|
||||
rel = file.relative_to(dest)
|
||||
assert (source / rel).read_bytes() == raw
|
||||
files.append({'path': rel.as_posix(), 'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()})
|
||||
log = trial / 'evidence' / (name + '.log')
|
||||
log.write_bytes(run.stdout + run.stderr)
|
||||
record = {'utc': datetime.now(timezone.utc).isoformat(), 'snapshot': str(dest), 'command': command,
|
||||
'checker_sha256': hashlib.sha256(checker.read_bytes()).hexdigest(), 'exit': run.returncode, 'files': files}
|
||||
(trial / 'evidence' / (name + '.json')).write_text(json.dumps(record, indent=2) + '\n', encoding='utf-8', newline='\n')
|
||||
print(run.stdout.decode('utf-8', errors='replace'))
|
||||
print(json.dumps({'name': name, 'exit': run.returncode, 'files': len(files), 'diagnostic_log': str(log)}))
|
||||
sys.exit(run.returncode)
|
||||
Reference in New Issue
Block a user