38 lines
2.0 KiB
Python
38 lines
2.0 KiB
Python
"""Package B3 evidence without changing or retouching application screenshots."""
|
|
import csv
|
|
import hashlib
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
from PIL import Image
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
source = root / 'e2e/shots/hel731'
|
|
out = root.parent / 'evidence/hel731'
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
for path in source.iterdir():
|
|
if path.is_file() and path.name != 'interaction-trace.zip':
|
|
shutil.copy2(path, out / path.name)
|
|
for actual in out.glob('*-actual.png'):
|
|
reference = actual.with_name(actual.name.replace('-actual', '-sample'))
|
|
left, right = Image.open(reference), Image.open(actual)
|
|
pair = Image.new('RGB', (left.width + right.width, max(left.height, right.height)))
|
|
pair.paste(left, (0, 0)); pair.paste(right, (left.width, 0))
|
|
pair.save(actual.with_name(actual.name.replace('-actual', '-pair')))
|
|
measurements = json.loads((source / 'measurements.json').read_text())
|
|
with (out / 'measurements.csv').open('w', newline='') as handle:
|
|
writer = csv.writer(handle)
|
|
writer.writerow(['page', 'theme', 'viewport', 'selector', 'property', 'sample', 'actual', 'delta'])
|
|
for row in measurements:
|
|
for key, sample in row['sample'].items():
|
|
actual = row['actual'][key]
|
|
delta = round(actual - sample, 5) if isinstance(sample, (int, float)) else ''
|
|
writer.writerow([row['page'], row['theme'], row['width'], row['selector'], key, sample, actual, delta])
|
|
logs = out / 'checks'; logs.mkdir(exist_ok=True)
|
|
for name in ['lint-b3.log', 'check-b3.log', 'build-b3.log', 'pytest-b3.log', 'frontend-test-b3.log', 'browser-b3.log', 'final-browser-b3.log', 'related-browser-b3.log', 'normalize-b3.log', 'theme-regression-b3.log']:
|
|
shutil.copy2(root / name, logs / name)
|
|
for suite in ['hel729', 'hel742']:
|
|
shutil.copy2(root / f'e2e/shots/{suite}/results.json', logs / f'{suite}-results.json')
|
|
shutil.copy2(root.parent / 'attachments/夜片场-多主题交互样本.html', out / 'approved-sample.html')
|
|
print('Evidence copied to', out.name)
|