Replaces the bpj2ini.py prototype with a packaged tool. The A2F codec is now reimplemented in Python, so neither Boxsim.exe nor a CPU emulator is needed to decode a container; the emulator survives as a development-only oracle that the codec is differentially tested against. Verified: - 134 containers decode byte-identically to Boxsim's own decoder, 270 pre-2.0 files rejected by both implementations (tools/difftest.py --self-test) - Default.BPJ: 22 components, 14 nets, no dangling terminal - 22 of 22 parts resolve to library symbols; one series inferred from a sibling, two DC resistance deviations reported - ERC clean and the netlist KiCad extracts from the generated sheet is an identical partition to the one derived from the Boxsim grid - container build byte-identical to the host build - 32 tests passing, ruff clean Decode time went 69 s -> 14.5 s (binding emulator hooks to trap addresses) -> 1.6 s (pure Python). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
74 lines
1.8 KiB
Python
74 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
DIST = ROOT / "boxsim_dl" / "BoxSim 2.1 DE (Stand 12.2025)"
|
|
DEFAULT_BPJ = DIST / "Projekte" / "Default.BPJ"
|
|
MANIFEST = ROOT / "tests" / "oracle_manifest.json"
|
|
|
|
|
|
def pytest_configure(config):
|
|
config.addinivalue_line("markers", "needs_kicad: requires kicad-cli 10 on PATH")
|
|
config.addinivalue_line("markers", "needs_dist: requires the Boxsim distribution")
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def dist() -> Path:
|
|
if not DIST.exists():
|
|
pytest.skip(f"Boxsim distribution not present at {DIST}")
|
|
return DIST
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def default_bpj(dist: Path) -> Path:
|
|
if not DEFAULT_BPJ.exists():
|
|
pytest.skip("Default.BPJ not present")
|
|
return DEFAULT_BPJ
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def manifest() -> dict:
|
|
if not MANIFEST.exists():
|
|
pytest.skip("oracle manifest missing; run tools/difftest.py")
|
|
return json.loads(MANIFEST.read_text(encoding="utf-8"))
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def kicad_cli() -> str:
|
|
exe = shutil.which("kicad-cli")
|
|
if exe is None:
|
|
pytest.skip("kicad-cli not on PATH")
|
|
return exe
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def library():
|
|
from boxsim import symbols
|
|
|
|
try:
|
|
return symbols.load()
|
|
except symbols.SymbolError as exc:
|
|
pytest.skip(str(exc))
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def catalog():
|
|
from boxsim import catalog as catalog_mod
|
|
|
|
try:
|
|
return catalog_mod.load()
|
|
except catalog_mod.CatalogError as exc:
|
|
pytest.skip(str(exc))
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def default_project(default_bpj: Path):
|
|
from boxsim import model
|
|
|
|
return model.load(default_bpj.read_bytes())
|