Skip to content

Conversation

@max-sixty
Copy link
Collaborator

Summary

  • Fix test_pending_snapshot_deletion failing when run under nextest
  • Clear NEXTEST_RUN_ID environment variable in functional test setup

When running functional tests under nextest, the NEXTEST_RUN_ID environment variable was inherited by child cargo insta test invocations. Since insta uses this variable as the RUN_ID for pending snapshots (see insta/src/snapshot.rs:18), all pending inline snapshots ended up sharing the same run_id.

This broke the cleanup mechanism in load_batch() which keeps all entries with the last run_id. When a test passed and wrote a NULL entry to mark the snapshot as clean, the previous failing entry was also kept (same run_id), preventing the .pending-snap file from being deleted.

Test plan

  • cargo test --package cargo-insta passes
  • cargo nextest run --package cargo-insta passes (previously failed on test_pending_snapshot_deletion)

🤖 Generated with Claude Code

When running functional tests under nextest, the NEXTEST_RUN_ID environment
variable was inherited by child `cargo insta test` invocations. This caused
all pending inline snapshots to share the same run_id, breaking the cleanup
mechanism that removes stale pending snapshots when tests pass.

The fix clears NEXTEST_RUN_ID in the test environment setup so each
cargo insta test invocation generates its own unique run_id.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit a711baf into mitsuhiko:master Nov 22, 2025
15 checks passed
@max-sixty max-sixty deleted the warning branch November 22, 2025 00:17
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 <noreply@anthropic.com>
@max-sixty max-sixty mentioned this pull request Nov 27, 2025
2 tasks
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
max-sixty added a commit to max-sixty/insta that referenced this pull request Nov 27, 2025
## Summary

- Fix `test_pending_snapshot_deletion` failing when run under nextest
- Clear `NEXTEST_RUN_ID` environment variable in functional test setup

When running functional tests under nextest, the `NEXTEST_RUN_ID`
environment variable was inherited by child `cargo insta test`
invocations. Since insta uses this variable as the `RUN_ID` for pending
snapshots (see `insta/src/snapshot.rs:18`), all pending inline snapshots
ended up sharing the same run_id.

This broke the cleanup mechanism in `load_batch()` which keeps all
entries with the last run_id. When a test passed and wrote a NULL entry
to mark the snapshot as clean, the previous failing entry was also kept
(same run_id), preventing the `.pending-snap` file from being deleted.

## Test plan

- [x] `cargo test --package cargo-insta` passes
- [x] `cargo nextest run --package cargo-insta` passes (previously
failed on `test_pending_snapshot_deletion`)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
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 <noreply@anthropic.com>
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