diff --git a/crates/test-macros/src/lib.rs b/crates/test-macros/src/lib.rs index 43b21855c8b1..7056ce391bd7 100644 --- a/crates/test-macros/src/lib.rs +++ b/crates/test-macros/src/lib.rs @@ -15,6 +15,15 @@ //! } //! ``` //! +//! To use just one specific compiler strategy: +//! +//! ```rust +//! #[wasmtime_test(strategies(only(Winch)))] +//! fn my_test(config: &mut Config) -> Result<()> { +//! Ok(()) +//! } +//! ``` +//! //! To explicitly indicate that a wasm features is needed //! ``` //! #[wasmtime_test(wasm_features(gc))] @@ -54,9 +63,27 @@ impl TestConfig { if meta.path.is_ident("Winch") { self.strategies.retain(|s| *s != Compiler::Winch); Ok(()) - } else if meta.path.is_ident("Cranelift") { + } else if meta.path.is_ident("CraneliftNative") { self.strategies.retain(|s| *s != Compiler::CraneliftNative); Ok(()) + } else if meta.path.is_ident("CraneliftPulley") { + self.strategies.retain(|s| *s != Compiler::CraneliftPulley); + Ok(()) + } else { + Err(meta.error("Unknown strategy")) + } + }) + } else if meta.path.is_ident("only") { + meta.parse_nested_meta(|meta| { + if meta.path.is_ident("Winch") { + self.strategies.retain(|s| *s == Compiler::Winch); + Ok(()) + } else if meta.path.is_ident("CraneliftNative") { + self.strategies.retain(|s| *s == Compiler::CraneliftNative); + Ok(()) + } else if meta.path.is_ident("CraneliftPulley") { + self.strategies.retain(|s| *s == Compiler::CraneliftPulley); + Ok(()) } else { Err(meta.error("Unknown strategy")) } @@ -97,7 +124,11 @@ impl TestConfig { impl Default for TestConfig { fn default() -> Self { Self { - strategies: vec![Compiler::CraneliftNative, Compiler::Winch], + strategies: vec![ + Compiler::CraneliftNative, + Compiler::Winch, + Compiler::CraneliftPulley, + ], flags: Default::default(), test_attribute: None, } @@ -193,7 +224,7 @@ fn expand(test_config: &TestConfig, func: Fn) -> Result { let mut tests = if test_config.strategies == [Compiler::Winch] { vec![quote! { // This prevents dead code warning when the macro is invoked as: - // #[wasmtime_test(strategies(not(Cranelift))] + // #[wasmtime_test(strategies(only(Winch))] // Given that Winch only fully supports x86_64. #[allow(dead_code)] #func diff --git a/tests/all/fuel.rs b/tests/all/fuel.rs index 3cb200f8e39b..aa84bab09f39 100644 --- a/tests/all/fuel.rs +++ b/tests/all/fuel.rs @@ -259,7 +259,7 @@ fn get_fuel_clamps_at_zero(config: &mut Config) -> Result<()> { Ok(()) } -#[wasmtime_test(strategies(not(Cranelift)))] +#[wasmtime_test(strategies(only(Winch)))] #[cfg_attr(miri, ignore)] fn ensure_stack_alignment(config: &mut Config) -> Result<()> { config.consume_fuel(true); diff --git a/tests/all/func.rs b/tests/all/func.rs index 574fb8964c58..375c7f02a1f8 100644 --- a/tests/all/func.rs +++ b/tests/all/func.rs @@ -2085,18 +2085,25 @@ fn typed_v128_imports(config: &mut Config) -> anyhow::Result<()> { #[cfg_attr(miri, ignore)] fn wrap_and_typed_i31ref(config: &mut Config) -> Result<()> { let engine = Engine::new(&config)?; - let mut store = Store::new(&engine, ()); + let mut store = Store::::new(&engine, AtomicUsize::new(0)); - static HITS: AtomicUsize = AtomicUsize::new(0); let mut linker = Linker::new(&engine); - linker.func_wrap("env", "i31ref", |x: Option| -> Option { - assert_eq!(HITS.fetch_add(1, Ordering::SeqCst), 0); - x - })?; - linker.func_wrap("env", "ref-i31", |x: I31| -> I31 { - assert_eq!(HITS.fetch_add(1, Ordering::SeqCst), 1); - x - })?; + linker.func_wrap( + "env", + "i31ref", + |caller: Caller<'_, AtomicUsize>, x: Option| -> Option { + assert_eq!(caller.data().fetch_add(1, Ordering::SeqCst), 0); + x + }, + )?; + linker.func_wrap( + "env", + "ref-i31", + |caller: Caller<'_, AtomicUsize>, x: I31| -> I31 { + assert_eq!(caller.data().fetch_add(1, Ordering::SeqCst), 1); + x + }, + )?; let module = Module::new( &engine, @@ -2128,7 +2135,7 @@ fn wrap_and_typed_i31ref(config: &mut Config) -> Result<()> { let x = ref_i31.call(&mut store, I31::wrapping_u32(0x1234))?; assert_eq!(x, I31::wrapping_u32(0x1234)); - assert_eq!(HITS.load(Ordering::SeqCst), 2); + assert_eq!(store.data().load(Ordering::SeqCst), 2); Ok(()) } diff --git a/tests/all/winch_engine_features.rs b/tests/all/winch_engine_features.rs index 99ba51702f4e..5f4e975f6c3a 100644 --- a/tests/all/winch_engine_features.rs +++ b/tests/all/winch_engine_features.rs @@ -1,7 +1,7 @@ use wasmtime::*; use wasmtime_test_macros::wasmtime_test; -#[wasmtime_test(strategies(not(Cranelift)))] +#[wasmtime_test(strategies(only(Winch)))] #[cfg_attr(miri, ignore)] fn ensure_compatibility_between_winch_and_table_lazy_init(config: &mut Config) -> Result<()> { config.table_lazy_init(false); @@ -21,7 +21,7 @@ fn ensure_compatibility_between_winch_and_table_lazy_init(config: &mut Config) - Ok(()) } -#[wasmtime_test(strategies(not(Cranelift)))] +#[wasmtime_test(strategies(only(Winch)))] #[cfg_attr(miri, ignore)] fn ensure_compatibility_between_winch_and_signals_based_traps(config: &mut Config) -> Result<()> { config.signals_based_traps(false); @@ -43,7 +43,7 @@ fn ensure_compatibility_between_winch_and_signals_based_traps(config: &mut Confi Ok(()) } -#[wasmtime_test(strategies(not(Cranelift)))] +#[wasmtime_test(strategies(only(Winch)))] #[cfg_attr(miri, ignore)] fn ensure_compatibility_between_winch_and_generate_native_debuginfo( config: &mut Config,