diff --git a/examples/hello-synchronization/Cargo.toml b/examples/hello-synchronization/Cargo.toml index ce3ed56e7..19b255fa9 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 36ce83f00..bcf360d57 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 f2d7de3f1..f61a0f298 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 d3e2676ad..915eef895 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};