Skip to content
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

Initialize empty schedules when calling .in_schedule if they do not already exist #7911

Merged
merged 8 commits into from
Mar 9, 2023

Conversation

SET001
Copy link
Member

@SET001 SET001 commented Mar 5, 2023

Objective

Fixes #7910

Solution

create shedule if it does not exist by the time add_system called

My first PR. Not sure how much this solution feet here but at least it seems to work. Any comment is appreciated.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2023

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Mar 5, 2023
@alice-i-cecile
Copy link
Member

create set if it does not exist by the time add_system called

This is not correct; you're creating a Schedule :)

@SET001
Copy link
Member Author

SET001 commented Mar 5, 2023

create set if it does not exist by the time add_system called

This is not correct; you're creating a Schedule :)

My mistake in PR description. Fixed it.

@SET001
Copy link
Member Author

SET001 commented Mar 5, 2023

also, maybe same changes might be applied in add_systems ?

Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

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

This behavior should be documented in the doc comments.

@alice-i-cecile
Copy link
Member

also, maybe same changes might be applied in add_systems ?

Yes, definitely. And agreed with James about the doc comments: I think .in_schedule is the best place for that.

@SET001
Copy link
Member Author

SET001 commented Mar 5, 2023

Isn't this part covered with some tests that also need to be updated? I can't find any...

Copy link
Member

@JoJoJet JoJoJet 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 the PR! I think this is a good change. In addition to the others' feedback, I have a bit of my own.

Also, please run cargo fmt --all. That should fix the CI issues :)

crates/bevy_app/src/app.rs Outdated Show resolved Hide resolved
@alice-i-cecile
Copy link
Member

Isn't this part covered with some tests that also need to be updated? I can't find any...

I'm not surprised if there aren't any: we tend not to test this sort of end-user API super hard since it gets caught readily in the examples.

That said, I'd be happy to see a pair of tests for this behavior, one for the single system case and the other for multiple systems.

@alice-i-cecile alice-i-cecile added this to the 0.11 milestone Mar 6, 2023
@SET001
Copy link
Member Author

SET001 commented Mar 6, 2023

how can I test that system runs on a specified schedule? Like in this example, to test that it runs not on default?

@alice-i-cecile
Copy link
Member

Use app.world.run_schedule(MySchedule) and then verify that the world was mutated as expected :)

@SET001
Copy link
Member Author

SET001 commented Mar 6, 2023

That said, I'd be happy to see a pair of tests for this behavior, one for the single system case and the other for multiple systems.

should these tests be integration tests, in bevy_app/tests or it will be ok to place them in crates/bevy_app/src/app.rs test section ?

@alice-i-cecile
Copy link
Member

The last one will work great here :)

@SET001
Copy link
Member Author

SET001 commented Mar 7, 2023

Yes, definitely. And agreed with James about the doc comments: I think .in_schedule is the best place for that.

maybe for add_system as well?

@SET001 SET001 requested review from JoJoJet and james7132 and removed request for JoJoJet March 8, 2023 16:14
Copy link
Member

@JoJoJet JoJoJet left a comment

Choose a reason for hiding this comment

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

This looks correct now. It's probably also worth mentioning in the docs for add_state that the OnEnter and OnExit schedules only get added if they don't already exist.

crates/bevy_app/src/config.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 8, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 9, 2023
@alice-i-cecile alice-i-cecile removed this pull request from the merge queue due to a manual request Mar 9, 2023
@alice-i-cecile alice-i-cecile changed the title add schedule if it is not exist yet Initialize empty schedules when calling .in_schedule if they do not already exist Mar 9, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 9, 2023
Merged via the queue into bevyengine:main with commit 3ec764e Mar 9, 2023
Shfty pushed a commit to shfty-rust/bevy that referenced this pull request Mar 19, 2023
Shfty pushed a commit to shfty-rust/bevy that referenced this pull request Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants