Fix snapshot keys being inconsistent with --rerun-each#23707
Conversation
|
Updated 3:57 PM PT - Oct 30th, 2025
❌ @pfgithub, your commit b3a85ce has 3 failures in
🧪 To try this PR locally: bunx bun-pr 23707That installs a local version of the PR into your bun-23707 --bun |
WalkthroughSets the snapshot writer's current file to null after freeing snapshot structures, removes a preemptive write when switching snapshot files, calls the snapshot writer during test reruns to reset state, and adds end-to-end tests validating snapshot-key consistency with --rerun-each. Changes
Possibly related PRs
Suggested reviewers
Pre-merge checks✅ Passed checks (4 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (3)**/*.zig📄 CodeRabbit inference engine (.cursor/rules/javascriptcore-class.mdc)
Files:
src/bun.js/**/*.zig📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)
Files:
src/**/*.zig📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)
Files:
🧠 Learnings (15)📓 Common learnings📚 Learning: 2025-09-30T22:53:19.887ZApplied to files:
📚 Learning: 2025-10-26T05:04:50.692ZApplied to files:
📚 Learning: 2025-08-30T00:13:36.815ZApplied to files:
📚 Learning: 2025-08-30T00:13:36.815ZApplied to files:
📚 Learning: 2025-08-30T00:13:36.815ZApplied to files:
📚 Learning: 2025-08-30T00:09:39.100ZApplied to files:
📚 Learning: 2025-08-30T00:13:36.815ZApplied to files:
📚 Learning: 2025-08-30T00:13:36.815ZApplied to files:
📚 Learning: 2025-08-30T00:13:36.815ZApplied to files:
📚 Learning: 2025-10-19T03:01:29.084ZApplied to files:
📚 Learning: 2025-10-12T02:22:34.373ZApplied to files:
📚 Learning: 2025-10-12T02:22:34.373ZApplied to files:
📚 Learning: 2025-08-30T00:12:56.803ZApplied to files:
📚 Learning: 2025-10-12T02:22:34.373ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
Comment |
093bdd2 to
e98fa47
Compare
f2ffa0a to
c3d32f9
Compare
When using --rerun-each, snapshot counters were not being reset between test reruns. This caused the second run to generate snapshot keys like "test name 2" instead of reusing "test name 1", triggering CI errors when snapshot creation is blocked. The fix unconditionally calls writeSnapshotFile() after each test file execution, which writes the snapshot file, closes it, clears all state (including counts), and sets _current_file to null. This ensures the next rerun starts fresh and generates consistent snapshot keys. This also simplifies getSnapshotFile() by removing the file_id check (no longer needed since _current_file is always null when entering that branch) and the redundant writeSnapshotFile() call (which would be a no-op since _current_file is null). Fixes #23705 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
c3d32f9 to
bacc77c
Compare
|
Closing this PR because it has been inactive for more than 90 days. |
Summary
--rerun-eachtest/regression/issue/23705Problem
When using
--rerun-each, snapshot counters were not being reset between test reruns. This caused:"test name 1"✅"test name 2"❌ (should be "test name 1")This triggered CI errors because Bun tried to create a new snapshot on the second run, which is blocked in CI environments.
Solution
Added
resetCountsForRerun()method to clear snapshot counts when starting a rerun (repeat_index > 0). This ensures snapshot keys remain consistent across all runs.Changes:
src/bun.js/test/snapshot.zig: AddedresetCountsForRerun()methodsrc/cli/test_command.zig: CallresetCountsForRerun()before each reruntest/regression/issue/23705/23705.test.ts: Regression tests for both inline and file snapshotsTest plan
rerun-each.test.tstests still passFixes #23705
🤖 Generated with Claude Code