mirror of
https://github.com/bevyengine/bevy
synced 2025-01-09 03:38:55 +00:00
d0f423d653
# Objective bevy_ecs has several compile_fail tests that assert lifetime safety. In the past, these tests have been green for the wrong reasons (see e.g. #2984). This PR makes sure, that they will fail if the compiler error changes. ## Solution Use [trybuild](https://crates.io/crates/trybuild) to assert the compiler errors. The UI tests are in a separate crate that is not part of the Bevy workspace. This is to ensure that they do not break Bevy's crater builds. The tests get executed by the CI workflow on the stable toolchain.
29 lines
1.2 KiB
Rust
29 lines
1.2 KiB
Rust
use xshell::{cmd, pushd};
|
|
|
|
fn main() {
|
|
// When run locally, results may differ from actual CI runs triggered by
|
|
// .github/workflows/ci.yml
|
|
// - Official CI runs latest stable
|
|
// - Local runs use whatever the default Rust is locally
|
|
|
|
// See if any code needs to be formatted
|
|
cmd!("cargo fmt --all -- --check")
|
|
.run()
|
|
.expect("Please run 'cargo fmt --all' to format your code.");
|
|
|
|
// See if clippy has any complaints.
|
|
// - Type complexity must be ignored because we use huge templates for queries
|
|
cmd!("cargo clippy --workspace --all-targets --all-features -- -D warnings -A clippy::type_complexity")
|
|
.run()
|
|
.expect("Please fix clippy errors in output above.");
|
|
|
|
// Run UI tests (they do not get executed with the workspace tests)
|
|
// - See crates/bevy_ecs_compile_fail_tests/README.md
|
|
{
|
|
let _bevy_ecs_compile_fail_tests = pushd("crates/bevy_ecs_compile_fail_tests")
|
|
.expect("Failed to navigate to the 'bevy_ecs_compile_fail_tests' crate");
|
|
cmd!("cargo test")
|
|
.run()
|
|
.expect("Compiler errors of the ECS compile fail tests seem to be different than expected! Check locally and compare rust versions.");
|
|
}
|
|
}
|