diff --git a/.config/nextest.toml b/.config/nextest.toml index 64b3b84cb..32c8d09d9 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -6,6 +6,10 @@ slow-timeout = { period = "45s", terminate-after = 2 } fail-fast = false retries = 0 +[profile.default-miri] +# Miri is very very slow, so give it a much longer timeout. +slow-timeout = { period = "120s", terminate-after = 4 } + # Use two threads for tests with "2 threads" in their name [[profile.default.overrides]] filter = 'test(~2_threads) | test(~2 threads)' diff --git a/naga/tests/naga/example_wgsl.rs b/naga/tests/naga/example_wgsl.rs index 5edb39af8..d9c642a1c 100644 --- a/naga/tests/naga/example_wgsl.rs +++ b/naga/tests/naga/example_wgsl.rs @@ -4,6 +4,9 @@ use naga::{front::wgsl, valid::Validator}; use std::{ffi::OsStr, fs, path::Path}; /// Runs through all example shaders and ensures they are valid wgsl. +// While we _can_ run this test under miri, it is extremely slow (>5 minutes), +// and naga isn't the primary target for miri testing, so we disable it. +#[cfg(not(miri))] #[test] pub fn parse_example_wgsl() { let example_path = Path::new(env!("CARGO_MANIFEST_DIR")) diff --git a/naga/tests/naga/snapshots.rs b/naga/tests/naga/snapshots.rs index e6e848deb..37a068d27 100644 --- a/naga/tests/naga/snapshots.rs +++ b/naga/tests/naga/snapshots.rs @@ -818,7 +818,9 @@ fn write_output_wgsl( input.write_output_file("wgsl", "wgsl", string); } -#[cfg(feature = "wgsl-in")] +// While we _can_ run this test under miri, it is extremely slow (>5 minutes), +// and naga isn't the primary target for miri testing, so we disable it. +#[cfg(all(feature = "wgsl-in", not(miri)))] #[test] fn convert_snapshots_wgsl() { let _ = env_logger::try_init(); @@ -843,7 +845,8 @@ fn convert_snapshots_wgsl() { } } -#[cfg(feature = "spv-in")] +// miri doesn't allow us to shell out to `spirv-as` +#[cfg(all(feature = "spv-in", not(miri)))] #[test] fn convert_snapshots_spv() { use std::process::Command; @@ -892,7 +895,9 @@ fn convert_snapshots_spv() { } } -#[cfg(feature = "glsl-in")] +// While we _can_ run this test under miri, it is extremely slow (>5 minutes), +// and naga isn't the primary target for miri testing, so we disable it. +#[cfg(all(feature = "glsl-in", not(miri)))] #[allow(unused_variables)] #[test] fn convert_snapshots_glsl() { diff --git a/player/tests/player/main.rs b/player/tests/player/main.rs index aa5eb90e7..ca0e728ae 100644 --- a/player/tests/player/main.rs +++ b/player/tests/player/main.rs @@ -245,6 +245,7 @@ impl Corpus { } } +#[cfg(not(miri))] #[test] fn test_api() { env_logger::init(); diff --git a/tests/Cargo.toml b/tests/Cargo.toml index d93f73389..95301df94 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -67,9 +67,11 @@ trybuild.workspace = true # Cargo-metadata doesn't compile on wasm due to old cargo-util-schemas dependency. cargo_metadata.workspace = true env_logger.workspace = true -nv-flip.workspace = true parking_lot = { workspace = true, features = ["deadlock_detection"] } +[target.'cfg(not(any(target_arch = "wasm32", miri)))'.dependencies] +nv-flip.workspace = true + # Webassembly [target.'cfg(target_arch = "wasm32")'.dependencies] console_log.workspace = true diff --git a/tests/src/image.rs b/tests/src/image.rs index dee861b22..5cb66a647 100644 --- a/tests/src/image.rs +++ b/tests/src/image.rs @@ -7,7 +7,7 @@ use wgpu::*; use crate::TestingContext; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(any(target_arch = "wasm32", miri)))] async fn read_png(path: impl AsRef, width: u32, height: u32) -> Option> { let data = match std::fs::read(&path) { Ok(f) => f, @@ -45,7 +45,7 @@ async fn read_png(path: impl AsRef, width: u32, height: u32) -> Option, width: u32, @@ -64,7 +64,7 @@ async fn write_png( writer.write_image_data(data).unwrap(); } -#[cfg_attr(target_arch = "wasm32", allow(unused))] +#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))] fn add_alpha(input: &[u8]) -> Vec { input .chunks_exact(3) @@ -72,7 +72,7 @@ fn add_alpha(input: &[u8]) -> Vec { .collect() } -#[cfg_attr(target_arch = "wasm32", allow(unused))] +#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))] fn remove_alpha(input: &[u8]) -> Vec { input .chunks_exact(4) @@ -81,7 +81,7 @@ fn remove_alpha(input: &[u8]) -> Vec { .collect() } -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(any(target_arch = "wasm32", miri)))] fn print_flip(pool: &mut nv_flip::FlipPool) { println!("\tMean: {:.6}", pool.mean()); println!("\tMin Value: {:.6}", pool.min_value()); @@ -115,7 +115,7 @@ pub enum ComparisonType { } impl ComparisonType { - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(any(target_arch = "wasm32", miri)))] fn check(&self, pool: &mut nv_flip::FlipPool) -> bool { match *self { ComparisonType::Mean(v) => { @@ -148,7 +148,7 @@ impl ComparisonType { } } -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(any(target_arch = "wasm32", miri)))] pub async fn compare_image_output( path: impl AsRef + AsRef, adapter_info: &wgpu::AdapterInfo, @@ -250,7 +250,7 @@ pub async fn compare_image_output( } } -#[cfg(target_arch = "wasm32")] +#[cfg(any(target_arch = "wasm32", miri))] pub async fn compare_image_output( path: impl AsRef + AsRef, adapter_info: &wgpu::AdapterInfo, @@ -259,13 +259,13 @@ pub async fn compare_image_output( test_with_alpha: &[u8], checks: &[ComparisonType], ) { - #[cfg(target_arch = "wasm32")] + #[cfg(any(target_arch = "wasm32", miri))] { let _ = (path, adapter_info, width, height, test_with_alpha, checks); } } -#[cfg_attr(target_arch = "wasm32", allow(unused))] +#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))] fn sanitize_for_path(s: &str) -> String { s.chars() .map(|ch| if ch.is_ascii_alphanumeric() { ch } else { '_' }) diff --git a/tests/tests/wgpu-compile/main.rs b/tests/tests/wgpu-compile/main.rs index f35a0cd24..e435171c4 100644 --- a/tests/tests/wgpu-compile/main.rs +++ b/tests/tests/wgpu-compile/main.rs @@ -1,3 +1,4 @@ +#![cfg(not(miri))] // Tests that ensure that various constructs that should not compile do not compile. #[test] diff --git a/tests/tests/wgpu-dependency/main.rs b/tests/tests/wgpu-dependency/main.rs index baf3f1bde..ac96afdb0 100644 --- a/tests/tests/wgpu-dependency/main.rs +++ b/tests/tests/wgpu-dependency/main.rs @@ -1,6 +1,6 @@ // Cargo-metadata doesn't compile on wasm due to old cargo-util-schemas dependency. // Since this test isn't dependent on the current architecture, we can just skip it on wasm without any issues. -#![cfg(not(target_arch = "wasm32"))] +#![cfg(not(any(target_arch = "wasm32", miri)))] use std::process::Command; diff --git a/tests/tests/wgpu-validation/api/instance.rs b/tests/tests/wgpu-validation/api/instance.rs index 4f30e9029..5385b71a2 100644 --- a/tests/tests/wgpu-validation/api/instance.rs +++ b/tests/tests/wgpu-validation/api/instance.rs @@ -1,5 +1,5 @@ mod multi_instance { - #![cfg(not(target_arch = "wasm32"))] + #![cfg(not(any(target_arch = "wasm32", miri)))] async fn get() -> wgpu::Adapter { let adapter = {