The JAR route makes the test ~50s; tag it so quick iteration can skip it while it still runs by default for validation.
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
"""Tests for the FreeRouting oracle harness (tests/oracle.py).
|
|
|
|
The routing test is gated on a live JVM + JAR and skips otherwise, so the suite
|
|
stays green without Java. When the maze router lands, its output SES will be
|
|
diffed against ``routed_net_set`` of the oracle SES here.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from oracle import HAS_ORACLE, requires_oracle, route_dsn, routed_net_set, routed_nets
|
|
|
|
FIXTURES = Path(__file__).parent / "dsn" / "fixtures"
|
|
ROUTABLE = FIXTURES / "kicad_routable.dsn"
|
|
|
|
|
|
def test_oracle_harness_imports():
|
|
# The harness must import and report availability even with no Java/JAR,
|
|
# so gated tests can skip cleanly instead of erroring at collection.
|
|
assert isinstance(HAS_ORACLE, bool)
|
|
|
|
|
|
@pytest.mark.oracle
|
|
@requires_oracle
|
|
def test_oracle_routes_and_reports_connectivity():
|
|
"""Reference FreeRouting routes a routable KiCad board and we can read it back.
|
|
|
|
Exercises the whole oracle path — JAR execution, SES production, and the
|
|
``routed_nets`` extraction that the router phase will diff against.
|
|
"""
|
|
ses = route_dsn(ROUTABLE, max_passes=5)
|
|
|
|
nets = routed_nets(ses)
|
|
assert nets, "SES network_out had no nets"
|
|
for counts in nets.values():
|
|
assert set(counts) == {"wires", "vias"}
|
|
|
|
routed = routed_net_set(ses)
|
|
assert routed, "oracle produced no routed nets on a routable board"
|
|
# Every routed net is a subset of all nets in the SES.
|
|
assert routed <= set(nets)
|