#!/usr/bin/env python3 """Verify removed history is optional, but live embedded documents remain required.""" from __future__ import annotations from pathlib import Path import shutil import sys from tempfile import TemporaryDirectory from preflight import check ROOT = Path(__file__).resolve().parents[2] # A compact 0.31.7 source tree may omit historical version-labelled documents. # It must still pass the same preflight used by every ./dev.sh command. assert check(ROOT) == [] with TemporaryDirectory(prefix="rustproxy-pruned-source-") as tmp: stripped = Path(tmp) / "RustProxy" shutil.copytree( ROOT, stripped, ignore=shutil.ignore_patterns(".git", "target", "data", ".upgrade-backup", "__pycache__"), ) # This functional document is in the Reader registry, but intentionally not # in the legacy hand-maintained required-file list. It must still be caught. reader_doc = stripped / "docs/REFERENCES.md" assert reader_doc.is_file(), "Missing test fixture: docs/REFERENCES.md" reader_doc.unlink() try: check(stripped) except ValueError as error: assert "Missing embedded Reader document: docs/REFERENCES.md" in str(error), error else: raise AssertionError("Preflight accepted missing compile-time embedded document") shutil.copy2(ROOT / "docs/REFERENCES.md", reader_doc) required_module = stripped / "src/cache/mod.rs" required_module.unlink() try: check(stripped) except ValueError as error: assert "missing src/cache/mod.rs" in str(error), error else: raise AssertionError("Preflight accepted missing runtime source") print("PASS: pruned historical documents are optional; embedded Reader files and runtime sources are mandatory.")