Added methods to modify Engine.time_scale for the duration of a single test #794
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
This
set_time_scalemethod 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 istime_scale_resetwhich resets the time scale set throughset_time_scaleand 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?