Merged
Conversation
Add a `RunSystem` extension trait to allow for immediate execution of systems on a `World` for debugging and/or testing purposes.
killercup
reviewed
Aug 7, 2023
Contributor
killercup
left a comment
There was a problem hiding this comment.
Looks like a neat helper for tests.
Co-authored-by: Pascal Hertleif <killercup@gmail.com>
hymm
approved these changes
Aug 10, 2023
Contributor
hymm
left a comment
There was a problem hiding this comment.
I like this api much better than the previous pr.
Not a huge fan of implementing on &mut App just for decreased verbosity. A little worse ergonomics for tests is fine and we're polluting the public api. But not worth blocking on.
Contributor
Author
I was debating that myself. Especially because compared to the previous PR, with this one you don't really need the app anymore to test systems, and in the few cases where we do want the app, using So I think you're right. I'll remove the implementation for |
Remove `RunSystem` impl for `&mut App`
hymm
approved these changes
Aug 11, 2023
cart
approved these changes
Aug 11, 2023
Merged
43 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add a
RunSystemextension trait to allow for immediate execution of systems on aWorldfor debugging and/or testing purposes.Objective
Fixes #6184
Initially, I made this CL as
ApplyCommands. After a discussion with @cart , we decided a more generic implementation would be better to support all systems. This is the new revised CL. Sorry for the long delay! 😅This CL allows users to do this:
Solution
This is implemented as a trait extension and not included in any preludes to ensure it's being used consciously.
Internally, it just initializes and runs a systems, and applies any deferred parameters all "in place".
The trait has 2 functions (one of which calls the other by default):
run_system_withis the general implementation, which allows user to pass system input parametersrun_systemis the ergonomic wrapper for systems with no input parameter (to avoid having the user pass()as input).Additionally, this trait is also implemented for(Removed based on feedback)&mut App. I added this mainly for ergonomics (app.run_systemvs.app.world.run_system).