From 3cc6a563ca06bbe69709661bc746a4a181cc24fc Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Sun, 22 Oct 2023 01:18:37 -0400 Subject: [PATCH] Re-add missing example tests (#4277) --- examples/hello-synchronization/Cargo.toml | 1 + examples/hello-synchronization/src/main.rs | 6 ++++++ examples/timestamp-queries/Cargo.toml | 1 + examples/timestamp-queries/src/main.rs | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/examples/hello-synchronization/Cargo.toml b/examples/hello-synchronization/Cargo.toml index ce3ed56e7c..19b255fa93 100644 --- a/examples/hello-synchronization/Cargo.toml +++ b/examples/hello-synchronization/Cargo.toml @@ -9,6 +9,7 @@ publish = false [[bin]] name = "hello-synchronization" path = "src/main.rs" +harness = false [dependencies] bytemuck.workspace = true diff --git a/examples/hello-synchronization/src/main.rs b/examples/hello-synchronization/src/main.rs index 36ce83f00a..bcf360d577 100644 --- a/examples/hello-synchronization/src/main.rs +++ b/examples/hello-synchronization/src/main.rs @@ -2,9 +2,11 @@ const ARR_SIZE: usize = 128; struct ExecuteResults { patient_workgroup_results: Vec, + #[cfg_attr(test, allow(unused))] hasty_workgroup_results: Vec, } +#[cfg_attr(test, allow(unused))] async fn run() { let instance = wgpu::Instance::default(); let adapter = instance @@ -187,6 +189,7 @@ async fn get_data( staging_buffer.unmap(); } +#[cfg(not(test))] fn main() { #[cfg(not(target_arch = "wasm32"))] { @@ -207,5 +210,8 @@ fn main() { } } +#[cfg(test)] +wgpu_test::gpu_test_main!(); + #[cfg(test)] mod tests; diff --git a/examples/timestamp-queries/Cargo.toml b/examples/timestamp-queries/Cargo.toml index f2d7de3f1e..f61a0f2981 100644 --- a/examples/timestamp-queries/Cargo.toml +++ b/examples/timestamp-queries/Cargo.toml @@ -9,6 +9,7 @@ publish = false [[bin]] name = "timestamp-queries" path = "src/main.rs" +harness = false [dependencies] bytemuck.workspace = true diff --git a/examples/timestamp-queries/src/main.rs b/examples/timestamp-queries/src/main.rs index d3e2676ad8..915eef8956 100644 --- a/examples/timestamp-queries/src/main.rs +++ b/examples/timestamp-queries/src/main.rs @@ -75,6 +75,7 @@ impl QueryResults { } } + #[cfg_attr(test, allow(unused))] fn print(&self, queue: &wgpu::Queue) { let period = queue.get_timestamp_period(); let elapsed_us = |start, end: u64| end.wrapping_sub(start) as f64 * period as f64 / 1000.0; @@ -174,6 +175,7 @@ impl Queries { } } +#[cfg_attr(test, allow(unused))] async fn run() { // Instantiates instance of wgpu let backends = wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all); @@ -403,6 +405,7 @@ fn render_pass( rpass.draw(0..3, 0..1); } +#[cfg(not(test))] fn main() { #[cfg(not(target_arch = "wasm32"))] { @@ -417,6 +420,9 @@ fn main() { } } +#[cfg(test)] +wgpu_test::gpu_test_main!(); + #[cfg(test)] mod tests { use wgpu_test::{gpu_test, GpuTestConfiguration};