8000 CATROID-799 Add Catrobat language test for SetGravityForAllActorsAndObjects brick by qlin93 · Pull Request #3848 · Catrobat/Catroid · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

CATROID-799 Add Catrobat language test for SetGravityForAllActorsAndObjects brick #3848

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 1 commit into from
Jan 9, 2021

Conversation

qlin93
Copy link
Contributor
@qlin93 qlin93 commented Oct 26, 2020

Added a new Catrobat language test for the SetGravityForAllActorsAndObjects brick.

https://jira.catrob.at/browse/CATROID-799

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

8000
Copy link
@Koell Koell left a comment

Choose a reason for hiding this comment

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

Please don't use Wait-functions, they tend to not work if the wait duration is to small on some slower devices and if the wait duration is to long the test gets unnecessarily too long.
A possible solution is to use Event-Bricks that wait for a condition to be true.

Additionaly the Finish Brick here might report "Success" before all asserts are checked.
This can be fixed if the finish brick is triggered when all assert are finished, if the finish brick is never reached the test will fail on time-out

In the attached version I provided a possible solution, (not the most elegant one, as the wait condition is also the same as the assert)

testSetGravityForAllActorsAndObjects.zip

Copy link
@Koell Koell left a comment

Choose a reason for hiding this comment

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

👍 the changes look good

Copy link
Member
@wslany wslany left a comment

Choose a reason for hiding this comment

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

Thanks.

However, the tests contain race conditions, where the outcome is implementation-dependent. For instance, in object Apple, the first script at the beginning executes the "Set your motion type" brick. Since the gravity vector by default is pointing down, the Apple starts to fall. Same for Apple2 as soon as the "Set your motion type" brick is executed in its first script. But you check only two bricks later, and for Apple2 also some bricks later, and not synchronized in a secure way, that the y velocity is still 0. This may not work on slow emulators, since the objects will have started to move already after the two bricks before the assert bricks, and thus they may have negative y velocities already. Also, the synchronization for Apple2 for the gravity set to 0 is not ensured, since there's no guarantee in which order the "When scene starts" scripts of the two objects are executed, and which bricks in the two objects are executed first in an interlaced, multithreaded order.

Also, since we have an Assert equal brick, there's no need to insert the equality test into the first parameter fields.

image

The synchronization via counting up the "velocity tested" variable is not easy to understand, and this can be done much simpler and clearer.

There are many ways how to fix this. Please think it through clearly once more and resubmit.

Copy link
@Koell Koell left a comment

Choose a reason for hiding this comment

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

👍 looks now more cleaner

Copy link
Member
@wslany wslany left a comment

Choose a reason for hiding this comment

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

Thanks, much better. However, there could still be race-condition problems making the test flaky, now on both slow and fast emulators (i.e., the latter mainly relevant hopefully in the future ;-) ), as follows:

For the Apple objects, in the first scripts, there is no brick between setting the motion type and the assertion. On fast emulators, the velocity thus could be 0 even with a non-zero gravity in the y direction. Therefore, please insert a "Wait 0.1 seconds" brick in between, at the point indicated with a "1" in the screenshot below. Then please test first that if the gravity has not been reset in the background, the assert in the first scripts would now fail, and document this in a reply in the comment section of the PR. If the test now doesn't fail in this case, increase the waiting time, e.g., to 0.2 or even larger, till the assert fails reliably. Then of course change the gravity back to 0 in the background, so that the assert works fine again.

For the second scripts of the Apple objects, there still is the problem on slow emulators that the velocity may not yet be negative, which could make the test flaky. Therefore, again insert a wait brick, now at position "2" indicated in the screenshot below, with the same time as in the case of the first scripts.

image

@qlin93 qlin93 force-pushed the CATROID-799 branch 4 times, most recently from cc8d1f9 to b210e8d Compare November 27, 2020 13:58
@qlin93
Copy link
Contributor Author
qlin93 commented Nov 27, 2020

Thanks, I tested it and the asserts in the first scripts fail reliably with a "Wait 0.1 seconds" when the gravity has not been set to 0.

Copy link
@Koell Koell left a comment

Choose a reason for hiding this comment

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

Thanks for adjusting the test

@wslany wslany merged commit 7ffaaca into Catrobat:develop Jan 9, 2021
@wslany
Copy link
Member
wslany commented Jan 9, 2021

Perfect, thanks a lot!

@qlin93 qlin93 deleted the CATROID-799 branch February 14, 2021 20:07
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.

3 participants
0