#!/usr/bin/env python3
"""Copy only shared test inputs; native constructions are independently owned."""
import argparse
from pathlib import Path
root = Path(__file__).resolve().parents[2]
destination = root / "haskell/test/spec"
sources = [root / "spec" / name for name in
("manifest.json", "model.json", "limits.json", "coverage.json", "vocabulary.json")]
sources += sorted((root / "spec/fixtures").rglob("*.json"))
parser = argparse.ArgumentParser()
parser.add_argument("--check", action="store_true")
args = parser.parse_args()
expected = {destination / source.relative_to(root / "spec"): source.read_bytes()
for source in sources}
stale = set(destination.rglob("*.json")) - expected.keys()
if stale:
raise SystemExit(f"Unexpected shared test inputs: {sorted(stale)}")
for path, content in expected.items():
if args.check:
if not path.exists() or path.read_bytes() != content:
raise SystemExit(f"Shared input is out of date: {path}")
else:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(content)
print(f"Shared test inputs verified: {len(expected)} files")