148 lines
6.1 KiB
Python
148 lines
6.1 KiB
Python
"""Bind actual GET, reversible text, screenshots and completed checks."""
|
|
|
|
import hashlib
|
|
import json
|
|
import re
|
|
import shutil
|
|
|
|
from build_definition import OUT, REF, REPO
|
|
from rebuild import BASE
|
|
|
|
BROWSER = REPO / ".local-evidence/h3-mv-document/browser"
|
|
|
|
|
|
def sha(raw):
|
|
return hashlib.sha256(raw).hexdigest()
|
|
|
|
|
|
def write(name, data):
|
|
(OUT / name).write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n")
|
|
|
|
|
|
def main():
|
|
actual = json.loads((BROWSER / "actual-get.json").read_bytes())
|
|
export = OUT / ("actual-" + actual["name"] + ".json")
|
|
doc = json.loads(export.read_bytes())
|
|
assert actual["doc_json"] == doc
|
|
shutil.copyfile(BROWSER / "actual-get.json", OUT / "actual-get.json")
|
|
write(
|
|
"get-binding.json",
|
|
dict(
|
|
workflow_id=actual["id"],
|
|
get_sha256=sha((BROWSER / "actual-get.json").read_bytes()),
|
|
export_sha256=sha(export.read_bytes()),
|
|
doc_json_equals_isolated_export=True,
|
|
comparison="Parsed JSON content equality, not original HTTP serialization bytes",
|
|
pins=json.loads((OUT / "pins.json").read_bytes()),
|
|
),
|
|
)
|
|
for p in (REPO / ".local-evidence").glob("mv-*.log"):
|
|
shutil.copyfile(p, OUT / (p.stem + ".txt"))
|
|
for name in ["setup-mv.py", "extend-mv.py", "extend-mv-final.py"]:
|
|
shutil.copyfile(REPO / ".local-evidence" / name, OUT / (name + ".txt"))
|
|
for name in ["mv-source-fetch.txt", "mv-source-extend.txt", "mv-source-final.txt"]:
|
|
shutil.copyfile(REPO / ".local-evidence" / name, OUT / name)
|
|
b = doc["fixed_version"]
|
|
browser = json.loads((OUT / "browser-results.json").read_bytes())
|
|
backend = json.loads((OUT / "backend-request-counts.json").read_bytes())
|
|
reports = list(OUT.parent.glob("音频MV*固定参考中文说明.md"))
|
|
assert len(reports) == 1
|
|
report = reports[0].read_text()
|
|
texts = []
|
|
for n in b["comments"]:
|
|
raw = n["text"]
|
|
literal = json.dumps(raw, ensure_ascii=False, indent=2)
|
|
assert "\n```json\n" + literal + "\n```" in report
|
|
assert json.loads(literal) == raw
|
|
renders = [r for r in browser["text_renderings"] if r["kind"] == "Note" + n["node_id"]]
|
|
assert len(renders) == 2 and all(r["decoded_sha256"] == sha(raw.encode()) for r in renders)
|
|
texts.append(
|
|
dict(
|
|
node_id=n["node_id"],
|
|
raw_codepoints=len(raw),
|
|
raw_sha256=sha(raw.encode()),
|
|
report_json_sha256=sha(literal.encode()),
|
|
decoded_sha256=sha(json.loads(literal).encode()),
|
|
CR=raw.count("\r"),
|
|
LF=raw.count("\n"),
|
|
literal_backslash_n=raw.count("\\n"),
|
|
tail_LF=raw.endswith("\n"),
|
|
browser_renderings=renders,
|
|
)
|
|
)
|
|
write("rendered-text-sha256.json", dict(raw_json_decoded_separate=True, notes=texts))
|
|
fields = []
|
|
original = json.loads((OUT / "definition-0.json").read_bytes())
|
|
for f, source_field in zip(b["fields"], original["fields"], strict=True):
|
|
assert f["pointer"] == source_field["pointer"]
|
|
assert f["value"] == source_field["value"]
|
|
literal = json.dumps(source_field["value"], ensure_ascii=False, indent=2)
|
|
assert "\n```json\n" + literal + "\n```" in report
|
|
assert json.loads(literal) == f["value"]
|
|
fields.append(
|
|
dict(
|
|
pointer=f["pointer"],
|
|
named_pointer=f["named_pointer"],
|
|
json_type=f["json_type"],
|
|
source_order_report_json_sha256=sha(literal.encode()),
|
|
get_json_sha256=sha(json.dumps(f["value"], ensure_ascii=False, indent=2).encode()),
|
|
named_json_sha256=sha(
|
|
json.dumps(f["named_value"], ensure_ascii=False, indent=2).encode()
|
|
),
|
|
)
|
|
)
|
|
write("saved-value-evidence.json", dict(saved_entries=135, fields=fields))
|
|
viewed = json.loads((OUT / "viewed-screenshots.json").read_bytes())
|
|
write(
|
|
"screenshot-review.json",
|
|
dict(
|
|
viewed=[dict(path=n, sha256=sha((BROWSER / n).read_bytes())) for n in viewed],
|
|
total=len(list(BROWSER.glob("*.png"))),
|
|
findings=(
|
|
"代表默认用途、版本缺口、实际latent链、CRLF注释、null与历史对象实际目验;"
|
|
"长文用DOM全文/SHA核对,不称逐字目验;无横溢,未改CSS/字体。"
|
|
),
|
|
),
|
|
)
|
|
tests = int(re.search(r"(\d+) passed", (OUT / "mv-tests-final.txt").read_text())[1])
|
|
frozen = json.loads((OUT / "baseline-frozen-files.json").read_bytes())
|
|
closure = json.loads((OUT / "source-closure.json").read_bytes())
|
|
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
|
|
write(
|
|
"validation-results.json",
|
|
dict(
|
|
base=BASE,
|
|
backend_tests=tests,
|
|
browser_assertions=browser["assertion_count"],
|
|
browser_groups=browser["assertionGroups"],
|
|
source_rows=len(rows),
|
|
source_closure_files=closure["count"],
|
|
accurate_nodes=26,
|
|
unresolved_implementation_nodes=1,
|
|
unknown_nodes=45,
|
|
saved_entries=135,
|
|
notes=3,
|
|
screenshots=len(list(BROWSER.glob("*.png"))),
|
|
viewed=len(viewed),
|
|
backend_fixed_gets=backend["fixed_count"],
|
|
browser_fixed_gets=browser["request_accounting"]["fixed_count"],
|
|
backend_polling_gets=backend["polling_count"],
|
|
browser_polling_gets=browser["request_accounting"]["polling_count"],
|
|
fixture_interceptions=len(browser["interceptions"]),
|
|
readiness_gets=1,
|
|
forbidden_requests=0,
|
|
frozen_baseline_files=frozen["count"],
|
|
old_fixed_blocks=129,
|
|
other_reviews=155,
|
|
frontend_build="rerun this batch",
|
|
full_browser="rerun this batch; no accumulation",
|
|
upstream_executed=False,
|
|
target_connected=False,
|
|
),
|
|
)
|
|
print("PASS actual GET/export,135 reversible entries,three raw/JSON/decoded/DOM note SHAs")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|