Skip to content

tests/misc/cexample_class: Fix timing sensitivity. #10072

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 2 commits into from
Nov 25, 2022

Conversation

laurensvalk
Copy link
Contributor

@laurensvalk laurensvalk commented Nov 24, 2022

This test could occasionally fail because some operations take longer than expected. This relaxes the timing constraints and defers printing until the very end.

Signed-off-by: Laurens Valk laurens@pybricks.com


This fixes a follow-up issue raised in #10038


Edit: While we are looking at this code, I've also added the Timer to the cexample module test.

@damz
Copy link
Contributor

damz commented Nov 24, 2022

Looks good to me 👍

print("Elapsed time should be approx. 100ms but it is", elapsed)
print(timer)
print(0 <= t_start <= TOLERANCE_MS)
print(0 <= t_end <= SLEEP_MS + TOLERANCE_MS)
Copy link
Member

Choose a reason for hiding this comment

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

how about a lower bound of SLEEP_MS - TOLERANCE_MS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Updated.

Now that the Timer class has been merged in a separate pull request,
this can be added to the module test too.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
This test could occasionally fail because some operations take longer
than expected. This relaxes the timing constraints and defers printing
until the very end.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
@dpgeorge dpgeorge merged commit 3c1a2a9 into micropython:master Nov 25, 2022
@dpgeorge
Copy link
Member

Thank for updating. Merged.

@laurensvalk laurensvalk deleted the user-type-example branch November 25, 2022 11:50
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