Skip to content

Commit

Permalink
add regression test for bevyengine#10385/bevyengine#10389
Browse files Browse the repository at this point in the history
  • Loading branch information
ickk committed Nov 17, 2023
1 parent bc9e159 commit a21752c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,36 @@ mod tests {
GenericLabel::<u64>(PhantomData).intern()
);
}

/// Custom runners should be in charge of when `app::update` gets called as they may need to
/// coordinate some state.
/// bug: https://github.com/bevyengine/bevy/issues/10385
/// fix: https://github.com/bevyengine/bevy/pull/10389
#[test]
fn regression_test_10385() {
use super::{Res, Resource};
use crate::PreUpdate;

#[derive(Resource)]
struct MyState {}

fn my_runner(mut app: App) {
let my_state = MyState {};
app.world.insert_resource(my_state);

for _ in 0..5 {
app.update();
}
}

fn my_system(_: Res<MyState>) {
// access state during app update
}

// Should not panic due to missing resource
App::new()
.set_runner(my_runner)
.add_systems(PreUpdate, my_system)
.run();
}
}

0 comments on commit a21752c

Please sign in to comment.