Skip to content

Conversation

@Curtis-Barnhart
Copy link
Contributor

Resolves #401

Issue 401 describes how the time_scale member of Engine can be changed to significantly speed up some types of tests (it can cause timing issues with others, so it should be used carefully). bitwes mentioned there that it would be good to have something built in to gut that could reset this value after tests were run so unexpected Engine time scales wouldn't bleed into other code.

This PR adds a member and two methods to the GutTest class that allow users to easily modify the Engine time scale for individual tests inside that test's code without needing to worry about cleaning up values. To change the time scale of any given test:

class ExampleTest:
    extends GutTest

    func test_something():
        set_time_scale(5.0)
        await wait_seconds(5.0)
        # By now, about 1 second has passed

This set_time_scale method can also be called inside before_each so that every method in a test runs on a given time scale. The time scale can also be set to multiple different values multiple times within a single test method, and after the method ends, it will always be reset to the original Engine value before the first set_time_scale was called. The other method is time_scale_reset which resets the time scale set through set_time_scale and can be called anytime during the test method by the user as well.

I will also regenerate the class reference as well as update the wiki documentation if this approach in the code is to your liking - I didn't want to write up a wiki description of how it worked until I knew that the approach was actually final, haha. Does this seem like an acceptable solution to the ideas proposed in 401?

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.

No mentions of Engine.set_time_scale

1 participant