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

[Merged by Bors] - Assert compiler errors for compile_fail tests #3067

Conversation

NiklasEi
Copy link
Member

@NiklasEi NiklasEi commented Nov 4, 2021

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 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.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Nov 4, 2021
@NiklasEi NiklasEi added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change and removed S-Needs-Triage This issue needs to be labelled labels Nov 4, 2021
@NiklasEi NiklasEi force-pushed the assert_compiler_errors_for_compile_fail_tests branch from 88e97ef to 6c7be3f Compare November 4, 2021 20:43
@cart
Copy link
Member

cart commented Nov 4, 2021

This is super useful and solves a very real problem. I feel so much safer now :)

@NiklasEi NiklasEi force-pushed the assert_compiler_errors_for_compile_fail_tests branch from 6c7be3f to ce8ad19 Compare November 4, 2021 21:24
@mockersf
Copy link
Member

mockersf commented Nov 6, 2021

Nice!

It will probably add to the things we need to update on a new rust version, and also fail things like crater builds. Would there be a way to run those kind of tests not on a simple cargo test but another command that we can add to our CI?

@NiklasEi
Copy link
Member Author

Maybe if we move them into a seperate crate that is not part of the workspace?

@NiklasEi NiklasEi force-pushed the assert_compiler_errors_for_compile_fail_tests branch from ce8ad19 to 0e05f04 Compare November 13, 2021 11:11
@NiklasEi
Copy link
Member Author

The UI tests are now moved into a separate crate that is not part of the Bevy workspace. They get executed by the CI workflow and should no longer be able to break Bevy's crater tests.

@mockersf
Copy link
Member

Could you fix the warning in CI

warning: bevy_ecs_ui_tests-tests v0.0.0 (/home/runner/work/bevy/bevy/crates/bevy_ecs_ui_tests/target/tests/bevy_ecs_ui_tests) ignoring invalid dependency `bevy_ecs_ui_tests` which is missing a lib target

It could be confusing in the future in case of other errors

@NiklasEi
Copy link
Member Author

Could you fix the warning in CI

I added an empty lib.rs pointing to the integration tests.

@NiklasEi
Copy link
Member Author

bors try

The redit link is failing to resolve...

bors bot added a commit that referenced this pull request Nov 13, 2021
@cart
Copy link
Member

cart commented Nov 13, 2021

Cool I think this is good to go, but I think the ui_test naming (despite being semi-standard) is a bit unintuitive / ambiguous with "UI as in GUI" tests. Maybe we should be a bit more specific and call this something like "bevy_ecs_compile_fail_tests" or "bevy_ecs_trybuild_tests".

@cart
Copy link
Member

cart commented Nov 13, 2021

bors r+

bors bot pushed a commit that referenced this pull request Nov 13, 2021
# 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.
@bors
Copy link
Contributor

bors bot commented Nov 13, 2021

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Nov 13, 2021
# 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.
@bors bors bot changed the title Assert compiler errors for compile_fail tests [Merged by Bors] - Assert compiler errors for compile_fail tests Nov 13, 2021
@bors bors bot closed this Nov 13, 2021
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-Code-Quality A section of code that is hard to understand or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants