mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
bdb4899978
# Objective
- Follow-up of #13184 :)
- We use `ui_test` to test compiler errors for our custom macros.
- There are four crates related to compile fail tests
- `bevy_ecs_compile_fail_tests`, `bevy_macros_compile_fail_tests`, and
`bevy_reflect_compile_fail_tests`, which actually test the macros.
-
[`bevy_compile_test_utils`](64c1c65783/crates/bevy_compile_test_utils
),
which provides helpers and common patterns for these tests.
- All of these crates reside within the `crates` directory.
- This can be confusing, especially for newcomers. All of the other
folders in `crates` are actual published libraries, except for these 4.
## Solution
- Move all compile fail tests to a `compile_fail` folder under their
corresponding crate.
- E.g. `crates/bevy_ecs_compile_fail_tests` would be moved to
`crates/bevy_ecs/compile_fail`.
- Move `bevy_compile_test_utils` to `tools/compile_fail_utils`.
There are a few benefits to this approach:
1. An internal testing detail is less intrusive (and confusing) for
those who just want to browse the public Bevy interface.
2. Follows a pre-existing approach of organizing related crates inside a
larger crate's folder.
- See `bevy_gizmos/macros` for an example.
4. Makes consistent the terms `compile_test`, `compile_fail`, and
`compile_fail_test` in code. It's all just `compile_fail` now, because
we are specifically testing the error messages on compiler failures.
- To be clear it can still be referred to by these terms in comments and
speech, just the names of the crates and the CI command are now
consistent.
## Testing
Run the compile fail CI command:
```shell
cargo run -p ci -- compile-fail
```
If it still passes, then my refactor was successful.
19 lines
539 B
TOML
19 lines
539 B
TOML
[package]
|
|
name = "bevy_reflect_compile_fail"
|
|
edition = "2021"
|
|
description = "Compile fail tests for Bevy Engine's reflection system"
|
|
homepage = "https://bevyengine.org"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
license = "MIT OR Apache-2.0"
|
|
publish = false
|
|
|
|
[dependencies]
|
|
# ui_test dies if we don't specify the version. See oli-obk/ui_test#211
|
|
bevy_reflect = { path = "../", version = "0.14.0-dev" }
|
|
|
|
[dev-dependencies]
|
|
compile_fail_utils = { path = "../../../tools/compile_fail_utils" }
|
|
|
|
[[test]]
|
|
name = "derive"
|
|
harness = false
|