test: encode eeschema kicad-cli ground truth (currently RED)

Update existing rotation/mirror assertions and add a kicad-cli-grounded
regression suite. eeschema's pin transform is verified against:
  - rotation: TRANSFORM(0,1,-1,0) for rot=90 — CCW in screen Y-down
  - mirror x: SYM_MIRROR_X = TRANSFORM(1,0,0,-1) — negates internal Y
  - mirror y: SYM_MIRROR_Y = TRANSFORM(-1,0,0,1) — negates internal X

Updated assertions:
  - test_pin_locator_y_flip: rotated cap pin 1 X 153.81 → 146.19
  - test_move_with_wire_preservation::test_resistor_rotated_90:
    pin 1 X 103.81 → 96.19
  - test_hierarchical_pad_net_map::test_90_degree_rotation:
    swapped UP_NET / DN_NET label coords

New file tests/test_pin_world_xy_eeschema_truth.py:
  - 4 parametrized diode tests via kicad-cli netlist (oracle = eeschema)
  - 2 parametrized resistor mirror tests via kicad-cli netlist
  - 3 pure-math pin_world_xy assertions for rot=90, mirror_x, mirror_y

Currently RED on rotation 90/270 (rotation direction) and mirror_x/y
(axis semantics swapped). Production fix in WireDragger.pin_world_xy
to follow.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-05-03 22:24:14 +01:00
parent 118318c2f3
commit f7660e15ad
4 changed files with 233 additions and 13 deletions

View File

@@ -420,17 +420,19 @@ class TestMultipleSubsheets:
@pytest.mark.unit
class TestRotatedSymbol:
def test_90_degree_rotation(self, iface, tmp_path):
"""A 90° CCW rotation maps pin (-1.27, 0) → (0, -1.27) in local coords."""
"""eeschema rot=90 is CCW in screen Y-down: TRANSFORM(0,1,-1,0).
Pin 1 lib (-1.27, 0) → internal (-1.27, 0) → (0,1,-1,0) applied = (0, 1.27)
→ world (10.0, 11.27).
Pin 2 lib ( 1.27, 0) → internal ( 1.27, 0) → (0,1,-1,0) applied = (0, -1.27)
→ world (10.0, 8.73).
Verified vs kicad-cli netlist on a Device:D rotated 90."""
sch = tmp_path / "top.kicad_sch"
sch.write_text(_build_sch_with_instances([("R1", "TestLib:R", 10.0, 10.0, 90)]))
# R1 at (10, 10), rotation=90°
# pin 1 (-1.27, 0) rotated 90° CCW → (0, -1.27) → abs (10.0, 8.73)
# pin 2 ( 1.27, 0) rotated 90° CCW → (0, 1.27) → abs (10.0, 11.27)
mock_sch = _sch_mock(
symbols=[_sym_mock("R1", "TestLib:R", 10.0, 10.0, rotation=90)],
global_labels=[
_lbl_mock("UP_NET", 10.0, 8.73),
_lbl_mock("DN_NET", 10.0, 11.27),
_lbl_mock("UP_NET", 10.0, 11.27),
_lbl_mock("DN_NET", 10.0, 8.73),
],
)
pad_net_map, _ = _call(iface, sch, mock_sch)