Files
prometeu-studio/tools/pbx-conformance/run.py
T

28 lines
1.8 KiB
Python

"""Build a production-loader harness without writing into the runtime checkout."""
import argparse
import json
import pathlib
import platform
import subprocess
import tempfile
parser = argparse.ArgumentParser()
parser.add_argument("--runtime", type=pathlib.Path, default=pathlib.Path("../runtime"))
parser.add_argument("--fixtures", type=pathlib.Path, default=pathlib.Path("prometeu-compiler/prometeu-build-pipeline/build/registry-conformance"))
parser.add_argument("--online", action="store_true", help="Allow Cargo to fetch uncached dependencies")
args = parser.parse_args()
runtime = args.runtime.resolve()
print("runtime", subprocess.check_output(["git", "-C", str(runtime), "rev-parse", "HEAD"], text=True).strip(), flush=True)
print("platform", platform.platform(), "limits=default capabilities=NONE", flush=True)
with tempfile.TemporaryDirectory(prefix="pbx-conformance-") as directory:
root = pathlib.Path(directory)
manifest = '[package]\nname="studio-pbx-conformance"\nversion="0.1.0"\nedition="2024"\n[dependencies]\n'
for crate in ["prometeu-bytecode", "prometeu-hal", "prometeu-vm", "prometeu-system"]:
manifest += f'{crate}={{path={json.dumps(str(runtime / "crates/console" / crate))}}}\n'
manifest += 'serde_json="1.0.149"\njsonschema={version="0.33",default-features=false}\n'
(root / "Cargo.toml").write_text(manifest)
(root / "Cargo.lock").write_text((runtime / "Cargo.lock").read_text())
(root / "src").mkdir()
(root / "src/main.rs").write_text(pathlib.Path(__file__).with_name("main.rs").read_text())
subprocess.run(["cargo", "run", *([] if args.online else ["--offline"]), "--manifest-path", str(root / "Cargo.toml"), "--", str(args.fixtures.resolve()), str(runtime / "devtools/headless-protocol/response.schema.json")], check=True)