test: add VM state snapshot integration test#477
Merged
Conversation
Loads all SB2/SB3 fixtures (with a few exclusions), captures a deterministic nested-block-tree snapshot of the resulting VM state, and compares against per-fixture JSON files in `tap-snapshots/vm-state-snapshot/`. Regenerate with `TAP_SNAPSHOT=1`. These snapshot files were generated with `scratch-blocks@1.3.0` to help ensure that `scratch-blocks@^2` leads to identical VM state. Also adds `test/fixtures/patch-timers.js` for tracking timer leaks across tests, which is one of the reasons that some projects were excluded from this new test.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds deterministic VM-state snapshot integration coverage to validate that projects load to an identical VM state across scratch-blocks@^1 vs scratch-blocks@^2, with snapshots stored under tap-snapshots/vm-state-snapshot/ and regeneration via TAP_SNAPSHOT=1.
Changes:
- Adds many per-fixture VM state snapshot JSON baselines for SB2/SB3 fixtures.
- Updates Scratch VM ESLint ignore list to exclude
tap-snapshots/**/*from linting.
Reviewed changes
Copilot reviewed 55 out of 121 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/scratch-vm/eslint.config.mjs | Ignores tap-snapshots/**/* so large generated snapshot artifacts don’t affect linting. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/operators-not-blank.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/monitors-stage-name.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/hat-thread-execution.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/event-when-green-flag.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/data-reporter-contents-local.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/data-reporter-contents-global.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/data-operators-local.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/data-operators-global.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/control-stop-all-leaks.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/control-if-true-then.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/control-if-true-then-else.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/control-if-false-then.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/control-if-false-then-else.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/execute/broadcast-wait-arg-change.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/event.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/edge-triggered-hat.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/draggable.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/default_nested.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/default.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/default.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/data.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/corrupt_svg.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/corrupt_svg.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/corrupt_sound.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/corrupt_png.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/corrupt_png.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/control.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/complex.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/comments_no_duplicate_id_serialization.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/comments.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/comments.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_simple.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_simple.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_local.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_local.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_limit.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_limit.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_exceeded_limit.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/cloud_variables_exceeded_limit.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/clone-cleanup.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/broadcast_special_chars.sb3.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/broadcast_special_chars.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/block-to-workspace-comments.sb2.json | Adds VM state snapshot baseline for fixture. |
| packages/scratch-vm/tap-snapshots/vm-state-snapshot/block-to-workspace-comments-without-scripts.sb2.json | Adds VM state snapshot baseline for fixture. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Contributor
Contributor
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Proposed Changes
Loads all SB2/SB3 fixtures (with a few exclusions), captures a deterministic nested-block-tree snapshot of the resulting VM state, and compares against per-fixture JSON files in
tap-snapshots/vm-state-snapshot/. Regenerate withTAP_SNAPSHOT=1.These snapshot files were generated with
scratch-blocks@1.3.0to help ensure thatscratch-blocks@^2leads to an identical VM state.Also adds
test/fixtures/patch-timers.jsfor tracking timer leaks across tests.Reason for Changes
This is intended to raise confidence in the correctness of
scratch-blocks@^2as well as the GUI and (especially) VM changes near it. The test verifies that the resulting VM state is identical to whatscratch-blocks@^1generated.Timer leaks prevented this test from working correctly with some projects; the timer tracking helped determine which projects to exclude.