Skip to content

fix(test): snapshot-schema audit tolerates CRLF checkout (unblocks v2.2.3 release)#326

Merged
doublegate merged 1 commit into
mainfrom
fix/snapshot-audit-crlf-windows
Jul 23, 2026
Merged

fix(test): snapshot-schema audit tolerates CRLF checkout (unblocks v2.2.3 release)#326
doublegate merged 1 commit into
mainfrom
fix/snapshot-audit-crlf-windows

Conversation

@doublegate

Copy link
Copy Markdown
Owner

Unblock the v2.2.3 release: fix the Windows-only snapshot_schema_audit failure

The v2.2.3 merge (#325) went green on the PR but failed on main, so release-auto.yml skipped and no release was cut. The PR CI matrix is Linux-only (the select matrix job trims it for pull requests); the main push runs the full matrix, and test (windows-latest) failed.

Root cause — CRLF, not logic

snapshot_schema_audit is a test added in this release (244e6c18), so the main push was its first Windows run. Two cases panicked in struct_fields with "unterminated struct body":

  • The chip source is embedded with include_str!, which captures the file with its on-disk line endings at compile time. A Windows checkout without an eol=lf attribute for .rs gives CRLF.
  • The struct-terminator search is LF-anchored — body.find("\n}\n") — and \r\n}\r\n does not contain \n}\n (it is \n}\r), so the search returned None and the unwrap_or_else panicked.
  • The sibling helpers already tolerate CRLF (writer_body's \n } survives inside \r\n }; touches_field's self.<field> needle never spans a line break), which is why only struct_fields failed.

Fix

Strip \r at the top of struct_fields (it returns owned Vec<String>, so a normalized local copy has no borrow implications), making every anchor line-ending-agnostic regardless of checkout.

Verification (deterministic — the PR matrix cannot run Windows)

Feeding a CRLF-converted real ppu.rs to the old anchor returns index -1 (the exact panic); to the fixed parser it returns a valid offset. Added struct_fields_tolerates_crlf_line_endings, which parses the same synthetic struct in both LF and CRLF form and asserts identical output — a pure string test, so Linux CI exercises the Windows guarantee too.

cargo test -p rustynes-test-harness --test snapshot_schema_audit   7 passed / 0 failed
clippy -p rustynes-test-harness --all-targets -D warnings          clean
fmt                                                                clean

On merge, the full main matrix (including windows-latest) validates the fix, and on success release-auto.yml cuts v2.2.3.

🤖 Generated with Claude Code

…indows)

The v2.2.3 merge went green on the PR but FAILED on `main`, blocking the
release. The PR's CI matrix is Linux-only (the `select matrix` job trims it
for pull requests); the `main` push runs the full matrix, and
`test (windows-latest)` failed in `snapshot_schema_audit` -- a test added in
this very release (`244e6c18`), so this is its first Windows run.

Two of its cases panicked in `struct_fields` with "unterminated struct
body". Root cause is line endings, not logic: the chip source is embedded
with `include_str!`, which captures the file with the on-disk endings at
compile time, and a Windows checkout without an `eol=lf` attribute for `.rs`
yields CRLF. The struct-terminator search is LF-anchored -- `body.find("\n}\n")`
-- and `\r\n}\r\n` does NOT contain `\n}\n` (it is `\n}\r`), so the search
returned None and the `unwrap_or_else` panicked. The sibling helpers already
tolerate CRLF and passed: `writer_body`'s `\n    }` anchor survives inside
`\r\n    }`, and `touches_field`'s `self.<field>` needle never spans a line
break -- only `struct_fields` had the LF-only terminator.

Fix: strip `\r` at the top of `struct_fields` (it returns owned `Vec<String>`,
so a normalized local copy has no borrow implications), making every anchor
and the line scan line-ending-agnostic regardless of how the file was
checked out.

Proven deterministically rather than by waiting on Windows CI (which the PR
matrix cannot exercise): feeding a CRLF-converted real `ppu.rs` to the old
anchor returns index -1 (the exact panic), and to the fixed parser returns a
valid offset. Added `struct_fields_tolerates_crlf_line_endings`, which parses
the same synthetic struct in both LF and CRLF form and asserts identical
output; being a pure string test it runs on Linux CI too, so the guarantee
holds on every platform rather than only where the audit happens to be
checked out LF.

Verification: `cargo test -p rustynes-test-harness --test snapshot_schema_audit`
7 passed / 0 failed; clippy -p rustynes-test-harness --all-targets -D warnings
clean; fmt clean.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@doublegate, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d134a6f9-fa16-4d0c-ab48-e5a61ef3946c

📥 Commits

Reviewing files that changed from the base of the PR and between 2db927c and ceee7ab.

📒 Files selected for processing (1)
  • crates/rustynes-test-harness/tests/snapshot_schema_audit.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/snapshot-audit-crlf-windows

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Antigravity review (Gemini via Ultra)

This PR normalizes CRLF line endings in struct_fields within snapshot_schema_audit.rs to prevent parser panics during test execution on Windows checkouts.

Blocking issues

None found.

Suggestions

  • crates/rustynes-test-harness/tests/snapshot_schema_audit.rs:266: src.replace('\r', "") unconditionally allocates a new String on every invocation, even for standard LF checkouts. Consider checking if src.contains('\r') or using std::borrow::Cow<str> to skip allocation when unnecessary.
  • crates/rustynes-test-harness/tests/snapshot_schema_audit.rs:267: let src = src.as_str(); is redundant; shadowing the owned String with a &str slice is unnecessary since &String dereferences to &str.

Nitpicks

  • crates/rustynes-test-harness/tests/snapshot_schema_audit.rs:519: write!(lf, ...) requires importing std::fmt::Write as _. Using push_str with format! avoids bringing the trait into scope.

Automated first-pass review by agy on a self-hosted runner -- not a human review.

@doublegate
doublegate merged commit fb51805 into main Jul 23, 2026
23 checks passed
@doublegate
doublegate deleted the fix/snapshot-audit-crlf-windows branch July 23, 2026 19:34
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