-
-
Notifications
You must be signed in to change notification settings - Fork 139
Fix backward compatibility for legacy inline snapshot format #830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes a regression introduced in 1.44.0 where existing inline snapshots using the legacy multiline format would fail to match. The problem: In 1.44.0, we changed how inline snapshots handle leading newlines (PR mitsuhiko#563). This caused snapshots like: insta::assert_snapshot!(value, @r" Unconflicted Mode(FILE) 0839b2e9412b "); to fail when the actual value is "Unconflicted Mode(FILE) 0839b2e9412b". The legacy format stored single-line content in a multiline raw string with source code indentation, which after processing becomes " Unconflicted...\n " - the leading spaces from indentation weren't being stripped in the comparison. The fix: In `matches_legacy`, detect the legacy single-line-in-multiline pattern by checking if the raw contents contain a newline but collapse to a single line after trimming. When this pattern is detected, apply `trim_start()` to strip the source code indentation artifacts. This ensures: - Legacy snapshots continue to pass (with a warning to update) - Modern single-line snapshots with intentional spaces are preserved - True multiline snapshots are unaffected We take backward compatibility seriously - upgrading insta should not cause existing valid tests to fail. Reported-by: jj-vcs/jj See: mitsuhiko#819 (comment) π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Collaborator
Author
|
summary done by Claude, as is some of the code... this fixes the small regression with leading white space on in a multiline snapshots with a single line of text |
max-sixty
added a commit
to max-sixty/insta
that referenced
this pull request
Nov 27, 2025
## Changes - Fix backward compatibility for legacy inline snapshot format. Snapshots using single-line content in multiline raw strings now correctly match again. (mitsuhiko#830) - Handle merge conflicts in snapshot files gracefully. When a snapshot file contains git merge conflict markers, insta now detects them and treats the snapshot as missing, allowing tests to continue and create a new pending snapshot for review. (mitsuhiko#829) - Skip nextest_doctest tests when cargo-nextest is not installed. (mitsuhiko#826) - Fix functional tests failing under nextest due to inherited `NEXTEST_RUN_ID` environment variable. (mitsuhiko#824) ## Version Updates - Bump version to 1.44.2 in `insta/Cargo.toml` and `cargo-insta/Cargo.toml` - Update CHANGELOG.md with release notes - Update Cargo.lock π€ Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
to max-sixty/insta
that referenced
this pull request
Nov 27, 2025
## Changes - Fix backward compatibility for legacy inline snapshot format. Snapshots using single-line content in multiline raw strings now correctly match again. (mitsuhiko#830) - Handle merge conflicts in snapshot files gracefully. When a snapshot file contains git merge conflict markers, insta now detects them and treats the snapshot as missing, allowing tests to continue and create a new pending snapshot for review. (mitsuhiko#829) - Skip nextest_doctest tests when cargo-nextest is not installed. (mitsuhiko#826) - Fix functional tests failing under nextest due to inherited `NEXTEST_RUN_ID` environment variable. (mitsuhiko#824) ## Version Updates - Bump version to 1.44.2 in `insta/Cargo.toml` and `cargo-insta/Cargo.toml` - Update CHANGELOG.md with release notes - Update Cargo.lock π€ Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 27, 2025
## Summary Prepare for the 1.44.2 patch release with four changes since 1.44.1. ## Changes - Fix backward compatibility for legacy inline snapshot format. Snapshots using single-line content in multiline raw strings now correctly match again. (#830) - Handle merge conflicts in snapshot files gracefully. When a snapshot file contains git merge conflict markers, insta now detects them and treats the snapshot as missing, allowing tests to continue and create a new pending snapshot for review. (#829) - Skip nextest_doctest tests when cargo-nextest is not installed. (#826) - Fix functional tests failing under nextest due to inherited `NEXTEST_RUN_ID` environment variable. (#824) ## Version Updates - Bump version to 1.44.2 in `insta/Cargo.toml` and `cargo-insta/Cargo.toml` - Update CHANGELOG.md with release notes - Update Cargo.lock ## Test plan - [x] All tests pass - [x] Pre-commit lints pass π€ Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
to max-sixty/insta
that referenced
this pull request
Nov 27, 2025
β¦ko#830) ## Summary This fixes a regression introduced in 1.44.0 where existing inline snapshots using the legacy multiline format would fail to match. **The problem:** PR mitsuhiko#563 changed how inline snapshots handle leading newlines. This caused snapshots like: ```rust insta::assert_snapshot!(value, @r" Unconflicted Mode(FILE) 0839b2e9412b "); ``` to fail when the actual value is `"Unconflicted Mode(FILE) 0839b2e9412b"`. The legacy format stored single-line content in a multiline raw string with source code indentation. After `from_inline_literal` processing, this becomes `" Unconflicted...\n "` β the leading spaces from code indentation weren't being stripped in the legacy comparison path. **The fix:** In `matches_legacy`, detect the legacy single-line-in-multiline pattern: ```rust let is_legacy_single_line_in_multiline = sc.contents.contains('\n') && sc.contents.trim_end().lines().count() <= 1; ``` When this pattern is detected, apply `trim_start()` to strip the source code indentation artifacts. This ensures: - β Legacy snapshots continue to pass (with a warning to update) - β Modern single-line snapshots with intentional leading spaces are preserved - β True multiline snapshots are unaffected ## Test plan - [x] Added 8 comprehensive functional tests covering: - Single-line content in multiline format (the jj bug) - Raw string multiline variant - Force update reformatting works - True multiline content unaffected - Multiline with relative indentation preserved - Intentional leading spaces correctly fail (no false positives) - Trailing whitespace line edge case - Empty snapshot edge case - [x] All 72 functional tests pass - [x] Full test suite passes Reported-by: jj-vcs/jj See: mitsuhiko#819 (comment) π€ Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
to max-sixty/insta
that referenced
this pull request
Nov 27, 2025
## Summary Prepare for the 1.44.2 patch release with four changes since 1.44.1. ## Changes - Fix backward compatibility for legacy inline snapshot format. Snapshots using single-line content in multiline raw strings now correctly match again. (mitsuhiko#830) - Handle merge conflicts in snapshot files gracefully. When a snapshot file contains git merge conflict markers, insta now detects them and treats the snapshot as missing, allowing tests to continue and create a new pending snapshot for review. (mitsuhiko#829) - Skip nextest_doctest tests when cargo-nextest is not installed. (mitsuhiko#826) - Fix functional tests failing under nextest due to inherited `NEXTEST_RUN_ID` environment variable. (mitsuhiko#824) ## Version Updates - Bump version to 1.44.2 in `insta/Cargo.toml` and `cargo-insta/Cargo.toml` - Update CHANGELOG.md with release notes - Update Cargo.lock ## Test plan - [x] All tests pass - [x] Pre-commit lints pass π€ Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This fixes a regression introduced in 1.44.0 where existing inline snapshots using the legacy multiline format would fail to match.
The problem: PR #563 changed how inline snapshots handle leading newlines. This caused snapshots like:
to fail when the actual value is
"Unconflicted Mode(FILE) 0839b2e9412b".The legacy format stored single-line content in a multiline raw string with source code indentation. After
from_inline_literalprocessing, this becomes" Unconflicted...\n "β the leading spaces from code indentation weren't being stripped in the legacy comparison path.The fix: In
matches_legacy, detect the legacy single-line-in-multiline pattern:When this pattern is detected, apply
trim_start()to strip the source code indentation artifacts.This ensures:
Test plan
Reported-by: jj-vcs/jj
See: #819 (comment)
π€ Generated with Claude Code