bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add test plugin group

Open anchpop opened this issue 3 years ago • 5 comments
trafficstars

Objective

Work towards closing #5931

Solution

  • Add a TestPlugins group that adds MinimalPlugins, AssetPlugin, ScenePlugin, WindowPlugin, GilrsPlugin, TransformPlugin, HierarchyPlugin, DiagnosticsPlugin, and InputPlugin.
  • Added an example for how to use it. The example gets run in CI, which should make sure that no future change ever breaks any of the plugins in Github Actions

Limitations

  • bevy_rapier will not work as it depends on RenderPlugin, but this is fixed in #5933.
  • While this is usable, LogPlugin cannot be added until #4934 is resolved

Changelog

Added

TestPlugins group that adds plugins suitable for use in automated tests.

anchpop avatar Sep 09 '22 21:09 anchpop

I would rather have a feature that would enable only what is interesting in CI than a plugin group. The feature would help reducing compile time.

mockersf avatar Sep 09 '22 21:09 mockersf

I would rather have a feature that would enable only what is interesting in CI than a plugin group. The feature would help reducing compile time.

Any tests that run can't have WinitPlugin, and as far as I can tell there's no way to tell cargo to automatically compile bevy with different features when running cargo test. Even if there were, I want to leave open the possibility of having a custom test harness that allows you to re-run failing tests using DefaultPlugins so you can see what's going on.

anchpop avatar Sep 09 '22 21:09 anchpop

The example should live in the root level tests directory, which will avoid the shenanigans :) We should try and publicize that better though; perhaps we can add a note to the examples README?

Done. There was already how_to_test_systems.rs, but I kept my example because it's much simpler than the other one.

anchpop avatar Sep 10 '22 02:09 anchpop

@mockersf I want your opinion on the organization here. I think it's interesting that we're linking to this from the examples README / including it in the cargo.toml. Unsure if it's the right choice!

alice-i-cecile avatar Sep 10 '22 14:09 alice-i-cecile

@mockersf I want your opinion on the organization here. I think it's interesting that we're linking to this from the examples README / including it in the cargo.toml. Unsure if it's the right choice!

One problem with this structure is that it causes cargo to print Warning: file tests/automated_tests.rs is included in multiple build targets (or something along those lines, I'm working from memory). But CI fails I include it in the examples page without including it in Cargo.toml, because running cargo run -p build-example-pages fails (as it detects there is something in the examples page that it thinks should not be there).

anchpop avatar Sep 10 '22 15:09 anchpop

When I test something on CI I add only plugins I need. So I wouldn't add a specific plugin group.

Shatur avatar Sep 17 '22 20:09 Shatur

Closing out; I don't think this is a reliable enough solution to include at the engine level.

alice-i-cecile avatar Sep 18 '22 15:09 alice-i-cecile