Skip to content

fix(core): normalize CRLF line endings and cap diff output in SnapshotComparator - #6

Open
YashDoesCode wants to merge 2 commits into
mainfrom
fix/comparator-crlf-handling
Open

YashDoesCode wants to merge 2 commits into
mainfrom
fix/comparator-crlf-handling

Conversation

@YashDoesCode

Copy link
Copy Markdown
Owner

Summary

Improves SnapshotComparator to normalize carriage return line endings (\r\n and \r to \n) by default, preventing spurious snapshot test failures on Windows git checkouts. Also introduces configurable maximum diff truncation to guard against memory exhaustion and terminal flooding on large mismatches.

Key Changes

  1. Cross-Platform CRLF Normalization:
    • By default, normalizes CRLF (\r\n) and CR (\r) to LF (\n) prior to comparison.
    • Prevents tests recorded on Linux/macOS from failing on Windows where git's core.autocrlf converts line endings.
    • Optional constructor new SnapshotComparator(false) allows strict byte-level line ending comparisons when desired.
  2. Diff Size Limiting & Memory Guard:
    • Caps displayed diff lines at maxDiffs (default: 100 entries, configurable).
    • Large snapshot diffs append a clean ... and N more line differences summary instead of overwhelming terminal logs and memory.
  3. Empty Snapshot Handling:
    • Properly handles empty snapshot baselines and outputs clean line diff diagnostics.

Verification

  • mvn verify: BUILD SUCCESS (all 26 tests pass across mint-parent, mint-core, mint-junit5, mint-example).
  • Regression suite in SnapshotComparatorTest covers CRLF matching, strict comparison mismatch, diff truncation, and empty content.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d192acb7-321e-4329-824e-6869bf93a817
Commits

Reviewing files that changed from the base of the PR and between b31a051 and c419453.

Files selected for processing: 2

  • mint-core/src/main/java/io/mint/core/SnapshotComparator.java
  • mint-core/src/test/java/io/mint/core/SnapshotComparatorTest.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@YashDoesCode
YashDoesCode marked this pull request as ready for review November 17, 2026 10:47
Copilot AI balanced review requested due to automatic review settings November 17, 2026 10:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

2 participants