Skip to content

Add reference for runtime to blocks container #1941

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
merged 4 commits into from
Jan 30, 2019

Conversation

kchadha
Copy link
Contributor

@kchadha kchadha commented Jan 24, 2019

Resolves

Update

Closes #1942.

Added runtime to calls to Blocks constructor in tests since it was necessary for the new tests in the upcoming erroneous project saving work.

Proposed Changes

Add a reference to the runtime in each block container instance.

Thank you to @chrisgarrity for pairing on this!

Reason for Changes

This is work towards fixing erroneous project saving. We want to eventually be able to track actual project changes introduced by changes to the blocks (e.g. creating a new block, changing a block field) vs. always emitting a project change whenever we receive a blockly event (https://github.com/LLK/scratch-vm/blob/develop/src/engine/blocks.js#L493). We will eventually remove that line and make that emitProjectChanged call within each of the ___Block functions (moveBlock, changeBlock, createBlock, deleteBlock) when a change actually takes place.

Test Coverage

This is not a functionality change so we did not add any new tests.

We did add a warning for calling changeBlock without the blocks container having a reference to the runtime. Previously this was an optional argument and none of the tests are testing any runtime needing functionality. We have filed a tech debt issue (#1942) to update all the tests to pass in a runtime when creating a new blocks container instance. We added a reference to the runtime to the existing calls to the Blocks constructor in the tests.

We also removed the optRuntime parameter that was being passed into blocklyListen in one of the tests since it is no longer needed. That test already follows a code path (e.g. deserializing a project) that will construct the blocks containers in the right way.

…here where it was being referenced. Update calls to blocks constructor.
… blockContainer. It wasn't being used by the tests or the playground and it is not an issue with actual project serialization. Update test to stop passing in runtime to blocklyListen function.
Copy link
Contributor

@paulkaplan paulkaplan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for including those test updates

@kchadha kchadha merged commit a9cf509 into scratchfoundation:develop Jan 30, 2019
@kchadha kchadha deleted the add-runtime-to-blocks branch January 30, 2019 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass in reference to runtime when creating new Blocks in the tests
3 participants