Skip to content

test: add VM state snapshot integration test#477

Merged
cwillisf merged 1 commit into
developfrom
test-vm-state-snapshot
Mar 14, 2026
Merged

test: add VM state snapshot integration test#477
cwillisf merged 1 commit into
developfrom
test-vm-state-snapshot

Conversation

@cwillisf
Copy link
Copy Markdown
Contributor

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 with TAP_SNAPSHOT=1.

These snapshot files were generated with scratch-blocks@1.3.0 to help ensure that scratch-blocks@^2 leads to an identical VM state.

Also adds test/fixtures/patch-timers.js for tracking timer leaks across tests.

Reason for Changes

This is intended to raise confidence in the correctness of scratch-blocks@^2 as well as the GUI and (especially) VM changes near it. The test verifies that the resulting VM state is identical to what scratch-blocks@^1 generated.

Timer leaks prevented this test from working correctly with some projects; the timer tracking helped determine which projects to exclude.

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.
@cwillisf cwillisf requested a review from Copilot March 14, 2026 07:33
@cwillisf cwillisf requested a review from a team as a code owner March 14, 2026 07:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 14, 2026

Test report for scratch-gui

  2 files  ±0   62 suites  ±0   10m 13s ⏱️ -5s
397 tests ±0  389 ✅ ±0  8 💤 ±0  0 ❌ ±0 
415 runs  ±0  407 ✅ ±0  8 💤 ±0  0 ❌ ±0 

Results for commit f4cff74. ± Comparison against base commit b1b3eae.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 14, 2026

Test report for scratch-vm

    1 files  ±  0    886 suites  +118   1m 58s ⏱️ +14s
1 916 tests +234  1 916 ✅ +234   0 💤 ±0  0 ❌ ±0 
5 218 runs  +352  5 188 ✅ +352  30 💤 ±0  0 ❌ ±0 

Results for commit f4cff74. ± Comparison against base commit b1b3eae.

♻️ This comment has been updated with latest results.

@cwillisf cwillisf merged commit b2771be into develop Mar 14, 2026
14 checks passed
@cwillisf cwillisf deleted the test-vm-state-snapshot branch March 14, 2026 07:46
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants