From c11477c468b844e60fb2f924e96b11c41c1e6330 Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Sun, 29 Dec 2024 22:50:27 +0100 Subject: [PATCH] Fix cargo test --all-features breaking rendering due to unity vertexes --- .github/workflows/rust.yml | 6 ++---- CONTRIBUTING.md | 3 ++- crates/egui/Cargo.toml | 4 ++++ crates/egui_demo_lib/tests/snapshots/demos/Code Editor.png | 4 ++-- crates/egui_demo_lib/tests/snapshots/demos/Code Example.png | 4 ++-- crates/epaint/Cargo.toml | 4 ++++ crates/epaint/src/mesh.rs | 4 ++-- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e2a5896980e..b1f5a5a370b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -238,12 +238,10 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Run tests - # TODO(lucasmerlin): Enable --all-features (currently this breaks the rendering in the tests because of the `unity` feature) - run: cargo test + run: cargo test --all-features - name: Run doc-tests - # TODO(lucasmerlin): Enable --all-features (currently this breaks the rendering in the tests because of the `unity` feature) - run: cargo test --doc + run: cargo test --all-features --doc - name: Upload artifacts uses: actions/upload-artifact@v4 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6777c9a156b..cfeb0c247ec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,8 @@ For small things, just go ahead an open a PR. For bigger things, please file an Browse through [`ARCHITECTURE.md`](ARCHITECTURE.md) to get a sense of how all pieces connects. You can test your code locally by running `./scripts/check.sh`. -There are snapshots test that might need to be updated. Run the tests with `UPDATE_SNAPSHOTS=true` to update them. +There are snapshots test that might need to be updated. +Run the tests with `UPDATE_SNAPSHOTS=true cargo test --workspace --all-features` to update all of them. For more info about the tests see [egui_kittest](./crates/egui_kittest/README.md). We use [git-lfs](https://git-lfs.com/) to store big files in the repository. diff --git a/crates/egui/Cargo.toml b/crates/egui/Cargo.toml index ce7999dd1f4..a0f11fdfa32 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -74,6 +74,10 @@ serde = ["dep:serde", "epaint/serde", "accesskit?/serde"] ## Change Vertex layout to be compatible with unity unity = ["epaint/unity"] +## Override and disable the unity feature +## This exists, so that when testing with --all-features, snapshots render correctly. +_override_unity = ["epaint/_override_unity"] + [dependencies] emath = { workspace = true, default-features = false } diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Code Editor.png b/crates/egui_demo_lib/tests/snapshots/demos/Code Editor.png index 77ebb00947f..703c9ef191d 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Code Editor.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Code Editor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b8ca5a27491c0589a97e43a70bc10dc52778d25ca3f7e7c895dbbbb784adfcfa -size 33245 +oid sha256:0a1099b85a1aaf20f3f1e091bc68259f811737feaefdfcc12acd067eca8f9117 +size 27083 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Code Example.png b/crates/egui_demo_lib/tests/snapshots/demos/Code Example.png index b835030147b..0f417f0b45a 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Code Example.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Code Example.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:37ba383a2ba7f00f8064d21203c22f9de2f688ea4fbd45d400c979187686cf33 -size 80861 +oid sha256:6969c6da67ea6cc7ebbbd7a2cc1cb13d4720befe28126367cbf2b2679d037674 +size 82363 diff --git a/crates/epaint/Cargo.toml b/crates/epaint/Cargo.toml index 0a4afde26b5..7201888728d 100644 --- a/crates/epaint/Cargo.toml +++ b/crates/epaint/Cargo.toml @@ -66,6 +66,10 @@ serde = ["dep:serde", "ahash/serde", "emath/serde", "ecolor/serde"] ## Change Vertex layout to be compatible with unity unity = [] +## Override and disable the unity feature +## This exists, so that when testing with --all-features, snapshots render correctly. +_override_unity = [] + [dependencies] emath.workspace = true ecolor.workspace = true diff --git a/crates/epaint/src/mesh.rs b/crates/epaint/src/mesh.rs index 2447cad293e..495759d041b 100644 --- a/crates/epaint/src/mesh.rs +++ b/crates/epaint/src/mesh.rs @@ -6,7 +6,7 @@ use emath::{Pos2, Rect, Rot2, TSTransform, Vec2}; /// Should be friendly to send to GPU as is. #[repr(C)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -#[cfg(not(feature = "unity"))] +#[cfg(any(not(feature = "unity"), feature = "_override_unity"))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))] pub struct Vertex { @@ -25,7 +25,7 @@ pub struct Vertex { #[repr(C)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -#[cfg(feature = "unity")] +#[cfg(all(feature = "unity", not(feature = "_override_unity")))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))] pub struct Vertex {