Advance native LaTeX execution and preview

This commit is contained in:
gloamxun committed 2026-11-18 22:17:21 +08:00
1 parent 91f9d76b16
commit 2741546ca8
414 files changed
+99872 -933

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
"""Audit strict native startup of an unmodified, entry-source-pinned format.
This records the first blocking diagnostic. A completed audit is not a
successful format boot; format_boot_passed remains false on native failure.
Transitive format dependencies and a portable fmt loader are not yet pinned.
"""
import argparse
import hashlib
import json
import re
from pathlib import Path
import subprocess
import tempfile
def main():
root = Path(__file__).resolve().parents[1]
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--binary", type=Path, default=root / "target/release/texrra")
parser.add_argument("--texmf", type=Path, required=True)
parser.add_argument("--manifest", type=Path, default=root / "tests/fixtures/native-format-entry.json")
parser.add_argument("--json", type=Path, required=True)
args = parser.parse_args()
manifest = json.loads(args.manifest.read_text())
entry = (args.texmf / manifest["entry"]).resolve()
before = hashlib.sha256(entry.read_bytes()).hexdigest()
if before != manifest["sha256"]:
raise SystemExit(f"format entry hash mismatch: {entry}; expected {manifest['sha256']}, got {before}")
with tempfile.TemporaryDirectory(prefix="texrra-native-format-") as temporary:
pdf = Path(temporary) / "format.pdf"
result = subprocess.run([str(args.binary.resolve()), "native", "--job", "--initex", "--etex", str(entry), str(pdf)],
capture_output=True, text=True, timeout=60, cwd=temporary)
after = hashlib.sha256(entry.read_bytes()).hexdigest()
assert before == after, "native format probe modified its source"
assert result.returncode == 0 or not pdf.exists(), "failed native execution wrote a PDF"
location = re.search(r"error: (.*):(\d+):(\d+): (.*)", result.stderr)
report = {
"audit_completed": True,
# A zero exit only proves execution reached the end. This slice
# has no native dump writer/loader, so it cannot certify a format.
"format_boot_passed": False,
"native_execution_completed": result.returncode == 0,
"profile": "native e-TeX job (partial; format-image completion is not certified)",
"entry": manifest["entry"],
"version": manifest["version"],
"sha256": before,
"source_unchanged": True,
"native_exit_code": result.returncode,
"first_blocker": {"source": location[1], "line": int(location[2]),
"column": int(location[3]), "message": location[4]} if location else None,
"diagnostic": result.stderr.strip(),
"stdout": result.stdout.strip(),
"job_files": {path.name: path.read_text() for path in Path(temporary).iterdir()
if path.is_file() and path.suffix in (".aux", ".log")},
"scope": "entry source only; transitive dependencies and fmt serialization are not certified",
}
args.json.write_text(json.dumps(report, indent=2) + "\n")
print(json.dumps(report, indent=2))
if __name__ == "__main__":
main()