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

bevy_math tests are broken #12729

Closed
spectria-limina opened this issue Mar 26, 2024 · 3 comments
Closed

bevy_math tests are broken #12729

spectria-limina opened this issue Mar 26, 2024 · 3 comments
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Bug An unexpected or incorrect behavior C-Testing A change that impacts how we test Bevy or how users test their apps

Comments

@spectria-limina
Copy link
Contributor

Bevy version

31d9146

What you did

cargo test -p bevy_math

What went wrong

   Compiling bevy_math v0.14.0-dev (/home/alercah/code/bevy/crates/bevy_math)
error[E0277]: the trait bound `glam::Vec3: RelativeEq<_>` is not satisfied
   --> crates/bevy_math/src/bounding/bounded3d/mod.rs:711:9
    |
711 | /         assert_relative_eq!(
712 | |             transformed.center,
713 | |             Vec3::new(2.0, std::f32::consts::SQRT_2 - 2.0, 5.0)
714 | |         );
    | |_________^ the trait `RelativeEq<_>` is not implemented for `glam::Vec3`
    |
    = help: the following other types implement trait `RelativeEq<Rhs>`:
              <f32 as RelativeEq>
              <f64 as RelativeEq>
              <Cell<T> as RelativeEq>
              <RefCell<T> as RelativeEq>
              <[A] as RelativeEq<[B]>>
              <&'a T as RelativeEq>
              <&'a mut T as RelativeEq>
note: required by a bound in `Relative`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:257:8
    |
255 | pub struct Relative<A, B = A>
    |            -------- required by a bound in this struct
256 | where
257 |     A: RelativeEq<B> + ?Sized,
    |        ^^^^^^^^^^^^^ required by this bound in `Relative`
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `glam::Vec3: RelativeEq<_>` is not satisfied
   --> crates/bevy_math/src/bounding/bounded3d/mod.rs:711:9
    |
711 | /         assert_relative_eq!(
712 | |             transformed.center,
713 | |             Vec3::new(2.0, std::f32::consts::SQRT_2 - 2.0, 5.0)
714 | |         );
    | |_________^ the trait `RelativeEq<_>` is not implemented for `glam::Vec3`
    |
    = help: the following other types implement trait `RelativeEq<Rhs>`:
              <f32 as RelativeEq>
              <f64 as RelativeEq>
              <Cell<T> as RelativeEq>
              <RefCell<T> as RelativeEq>
              <[A] as RelativeEq<[B]>>
              <&'a T as RelativeEq>
              <&'a mut T as RelativeEq>
note: required by a bound in `Relative::<A, B>::eq`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:282:8
    |
282 |     A: RelativeEq<B> + ?Sized,
    |        ^^^^^^^^^^^^^ required by this bound in `Relative::<A, B>::eq`
...
303 |     pub fn eq(self, lhs: &A, rhs: &B) -> bool {
    |            -- required by a bound in this associated function
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `glam::Vec3: AbsDiffEq` is not satisfied in `Relative<glam::Vec3>`
   --> crates/bevy_math/src/bounding/bounded3d/mod.rs:711:9
    |
711 | /         assert_relative_eq!(
712 | |             transformed.center,
713 | |             Vec3::new(2.0, std::f32::consts::SQRT_2 - 2.0, 5.0)
714 | |         );
    | |_________^ within `Relative<glam::Vec3>`, the trait `AbsDiffEq` is not implemented for `glam::Vec3`, which is required by `Relative<glam::Vec3>: Sized`
    |
    = help: the following other types implement trait `AbsDiffEq<Rhs>`:
              <isize as AbsDiffEq>
              <i8 as AbsDiffEq>
              <i16 as AbsDiffEq>
              <i32 as AbsDiffEq>
              <i64 as AbsDiffEq>
              <usize as AbsDiffEq>
              <u8 as AbsDiffEq>
              <u16 as AbsDiffEq>
            and 9 others
note: required because it appears within the type `Relative<glam::Vec3>`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:255:12
    |
255 | pub struct Relative<A, B = A>
    |            ^^^^^^^^
    = note: the return type of a function must have a statically known size
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `glam::Vec2: RelativeEq<_>` is not satisfied
   --> crates/bevy_math/src/rotation2d.rs:449:9
    |
449 |         assert_relative_eq!(rotation * Vec2::X, Vec2::Y);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `RelativeEq<_>` is not implemented for `glam::Vec2`
    |
    = help: the following other types implement trait `RelativeEq<Rhs>`:
              <f32 as RelativeEq>
              <f64 as RelativeEq>
              <Cell<T> as RelativeEq>
              <RefCell<T> as RelativeEq>
              <[A] as RelativeEq<[B]>>
              <&'a T as RelativeEq>
              <&'a mut T as RelativeEq>
note: required by a bound in `Relative`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:257:8
    |
255 | pub struct Relative<A, B = A>
    |            -------- required by a bound in this struct
256 | where
257 |     A: RelativeEq<B> + ?Sized,
    |        ^^^^^^^^^^^^^ required by this bound in `Relative`
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `glam::Vec2: RelativeEq<_>` is not satisfied
   --> crates/bevy_math/src/rotation2d.rs:449:9
    |
449 |         assert_relative_eq!(rotation * Vec2::X, Vec2::Y);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `RelativeEq<_>` is not implemented for `glam::Vec2`
    |
    = help: the following other types implement trait `RelativeEq<Rhs>`:
              <f32 as RelativeEq>
              <f64 as RelativeEq>
              <Cell<T> as RelativeEq>
              <RefCell<T> as RelativeEq>
              <[A] as RelativeEq<[B]>>
              <&'a T as RelativeEq>
              <&'a mut T as RelativeEq>
note: required by a bound in `Relative::<A, B>::eq`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:282:8
    |
282 |     A: RelativeEq<B> + ?Sized,
    |        ^^^^^^^^^^^^^ required by this bound in `Relative::<A, B>::eq`
...
303 |     pub fn eq(self, lhs: &A, rhs: &B) -> bool {
    |            -- required by a bound in this associated function
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `direction::Dir2: RelativeEq<_>` is not satisfied
   --> crates/bevy_math/src/rotation2d.rs:450:9
    |
450 |         assert_relative_eq!(rotation * Dir2::Y, Dir2::NEG_X);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `RelativeEq<_>` is not implemented for `direction::Dir2`
    |
    = help: the following other types implement trait `RelativeEq<Rhs>`:
              <f32 as RelativeEq>
              <f64 as RelativeEq>
              <Cell<T> as RelativeEq>
              <RefCell<T> as RelativeEq>
              <[A] as RelativeEq<[B]>>
              <&'a T as RelativeEq>
              <&'a mut T as RelativeEq>
note: required by a bound in `Relative`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:257:8
    |
255 | pub struct Relative<A, B = A>
    |            -------- required by a bound in this struct
256 | where
257 |     A: RelativeEq<B> + ?Sized,
    |        ^^^^^^^^^^^^^ required by this bound in `Relative`
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `direction::Dir2: RelativeEq<_>` is not satisfied
   --> crates/bevy_math/src/rotation2d.rs:450:9
    |
450 |         assert_relative_eq!(rotation * Dir2::Y, Dir2::NEG_X);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `RelativeEq<_>` is not implemented for `direction::Dir2`
    |
    = help: the following other types implement trait `RelativeEq<Rhs>`:
              <f32 as RelativeEq>
              <f64 as RelativeEq>
              <Cell<T> as RelativeEq>
              <RefCell<T> as RelativeEq>
              <[A] as RelativeEq<[B]>>
              <&'a T as RelativeEq>
              <&'a mut T as RelativeEq>
note: required by a bound in `Relative::<A, B>::eq`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:282:8
    |
282 |     A: RelativeEq<B> + ?Sized,
    |        ^^^^^^^^^^^^^ required by this bound in `Relative::<A, B>::eq`
...
303 |     pub fn eq(self, lhs: &A, rhs: &B) -> bool {
    |            -- required by a bound in this associated function
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `glam::Vec2: AbsDiffEq` is not satisfied in `Relative<glam::Vec2>`
   --> crates/bevy_math/src/rotation2d.rs:449:9
    |
449 |         assert_relative_eq!(rotation * Vec2::X, Vec2::Y);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Relative<glam::Vec2>`, the trait `AbsDiffEq` is not implemented for `glam::Vec2`, which is required by `Relative<glam::Vec2>: Sized`
    |
    = help: the following other types implement trait `AbsDiffEq<Rhs>`:
              <isize as AbsDiffEq>
              <i8 as AbsDiffEq>
              <i16 as AbsDiffEq>
              <i32 as AbsDiffEq>
              <i64 as AbsDiffEq>
              <usize as AbsDiffEq>
              <u8 as AbsDiffEq>
              <u16 as AbsDiffEq>
            and 9 others
note: required because it appears within the type `Relative<glam::Vec2>`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:255:12
    |
255 | pub struct Relative<A, B = A>
    |            ^^^^^^^^
    = note: the return type of a function must have a statically known size
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `direction::Dir2: AbsDiffEq` is not satisfied in `Relative<direction::Dir2>`
   --> crates/bevy_math/src/rotation2d.rs:450:9
    |
450 |         assert_relative_eq!(rotation * Dir2::Y, Dir2::NEG_X);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Relative<direction::Dir2>`, the trait `AbsDiffEq` is not implemented for `direction::Dir2`, which is required by `Relative<direction::Dir2>: Sized`
    |
    = help: the following other types implement trait `AbsDiffEq<Rhs>`:
              <isize as AbsDiffEq>
              <i8 as AbsDiffEq>
              <i16 as AbsDiffEq>
              <i32 as AbsDiffEq>
              <i64 as AbsDiffEq>
              <usize as AbsDiffEq>
              <u8 as AbsDiffEq>
              <u16 as AbsDiffEq>
            and 9 others
note: required because it appears within the type `Relative<direction::Dir2>`
   --> /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/approx-0.5.1/src/lib.rs:255:12
    |
255 | pub struct Relative<A, B = A>
    |            ^^^^^^^^
    = note: the return type of a function must have a statically known size
    = note: this error originates in the macro `relative_eq` which comes from the expansion of the macro `assert_relative_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `bevy_math` (lib test) due to 9 previous errors

Additional information

This appears to be because the implementations of approx types are not available when compiling for tests.

cargo test -p bevy_math --features approx fixes things.

@spectria-limina spectria-limina added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 26, 2024
@pablo-lua pablo-lua added C-Testing A change that impacts how we test Bevy or how users test their apps A-Math Fundamental domain-agnostic mathematical operations and removed S-Needs-Triage This issue needs to be labelled labels Mar 26, 2024
@BD103
Copy link
Member

BD103 commented Mar 26, 2024

Is there a way to enable the glam/approx feature when cfg(test) is true? That will fix it.

Alternatively, it may be possible to specific glam as a dev-dependency with the approx feature enabled. (glam = { version = "0.x", features = ["approx"] })

@OneFourth
Copy link
Contributor

Seems like the current way of doing this would be what's described here rust-lang/cargo#2911 (comment)

There is currently a work-around for this. (Source)

[dev-dependencies]
self-package-name= { path = ".", features = ["desired_feature"] }

where self-package-name is the name of the package in the Cargo.toml file.

Sample repo for the same

So we'd add this to bevy_math's dev-dependencies

bevy_math = { path = ".", features = ["approx"] }

github-merge-queue bot pushed a commit that referenced this issue Mar 27, 2024
# Objective

Fixes `cargo test -p bevy_math` as in #12729.

## Solution

As described in
[message](#12729 (comment))
Added workaround `bevy_math = { path = ".", version = "0.14.0-dev",
features = ["approx"] }` to `bevy_math`'s `dev-dependencies`

---------

Co-authored-by: BD103 <[email protected]>
@bugsweeper
Copy link
Contributor

bugsweeper commented Mar 29, 2024

PR #12748 , which is fix for this issue wasn't attached to this Issue, but it had been merged and closed. @spectria-limina can you close this Issue manualy if it isn't actual?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Bug An unexpected or incorrect behavior C-Testing A change that impacts how we test Bevy or how users test their apps
Projects
None yet
Development

No branches or pull requests

5 participants