Skip to content

test(sch): cover the sheet-pin branch of the junction reconciler - #332

Open
triglav-modular wants to merge 1 commit into
mixelpixx:mainfrom
triglav-modular:fix/120-sheet-pin-coverage
Open

test(sch): cover the sheet-pin branch of the junction reconciler#332
triglav-modular wants to merge 1 commit into
mixelpixx:mainfrom
triglav-modular:fix/120-sheet-pin-coverage

Conversation

@triglav-modular

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #330, closing the gap you flagged there rather than blocked on: attached = has_pin || has_sheet_pin had no test for its second half. Tests only — no behaviour change.

Approach

The branch is reachable exactly one way. Candidate points come from moved symbol pins, so the sheet-pin clause only decides anything when a symbol pin vacates a point a hierarchical sheet pin also holds. The fixture puts R1's pin, the sheet's SHPIN and the dot all at (139.7, 190.5) on a wire's interior; the test removes R1 — the post-move state — and asserts the dot survives on the sheet pin alone.

Its own fixture rather than an addition to junction_reconcile.kicad_sch. My first attempt added a sheet to the shared one, which perturbed the inputs of the six tests already merged against it and forced edits to bulk_move_prunes_the_junction_its_pin_vacates's dot counts. Adjusting merged assertions to accommodate a new test is the wrong trade, so this leaves them untouched.

Two details KiCad decided rather than me, both preserved in the committed text: a sheet pin snaps to the sheet border, so the sheet is placed with its right border on the target point and sized 30.48 (24 × 1.27) to land on the grid a symbol pin snaps to — my first attempt had the pin at 170.18 while the symbol pin sat at 139.7, silently not coincident and passing for the wrong reason. Its Sheetfile names an existing fixture so the reference resolves rather than dangling.

Compatibility and safety

None — no source behaviour changes, no public names, no schema. One new fixture file and one test plus its helper.

The helper that strips the symbol is guarded, because a silent failure here is invisible: reconcile_junctions_at returns its input unchanged when the sheet does not parse, which is exactly what a passing sheet-pin test looks like. It asserts the symbol is gone and the parens balance.

Validation

  • cargo fmt --all -- --check
  • cargo test --workspace --locked --lib --tests — 768 pass, 1 ignored
  • cargo test --workspace --locked --doc
  • cargo clippy --workspace --locked --all-targets -- -D warnings

Two mutation checks, since a test that merely runs near a branch is not coverage:

  • deleting || idx.has_sheet_pin(px, py)this test fails, and only this test
  • sabotaging the strip helper's paren balancing → fails loudly rather than going green

Fixture is kicad-cli sch upgrade output and byte-identical to a fresh rewrite, so the provenance claim is checkable.

🤖 Generated with Claude Code

`attached = has_pin || has_sheet_pin` had no test for its second half —
noted on mixelpixx#330 as not blocking. This covers it.

The branch is only reachable one way: candidate points come from moved
*symbol* pins, so the sheet-pin clause decides something only when a symbol
pin vacates a point a hierarchical sheet pin also holds. The fixture puts
R1's pin, the sheet's SHPIN and the dot all at (139.7, 190.5) on a wire's
interior; the test removes R1 — the post-move state — and asserts the dot
survives on the sheet pin alone. Verified by mutation: deleting the
`|| has_sheet_pin` clause fails this test and nothing else.

Its own fixture rather than an addition to junction_reconcile.kicad_sch, so
the six tests already merged against that sheet keep the inputs they were
written for and no existing assertion has to be adjusted.

Fixture is eeschema's own output via `kicad-cli sch upgrade`. Two things
KiCad decided rather than me: a sheet pin snaps to the sheet border, so the
sheet is placed with its right border on the target point and sized 30.48
(24 * 1.27) to land on the grid a symbol pin snaps to; and its Sheetfile
names an existing fixture, so the reference resolves rather than dangling.

The helper that strips the symbol is guarded. `reconcile_junctions_at`
returns its input unchanged when the sheet does not parse, which is
indistinguishable from a passing sheet-pin test, so the helper asserts the
symbol is gone and the parens balance. Verified that sabotaging it fails the
test rather than letting it go quietly green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant