diff --git a/lib/middleware-common-tests/Cargo.toml b/lib/middleware-common-tests/Cargo.toml index f86e6189a..72e84c879 100644 --- a/lib/middleware-common-tests/Cargo.toml +++ b/lib/middleware-common-tests/Cargo.toml @@ -10,12 +10,12 @@ publish = false [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.12.0" } wasmer-middleware-common = { path = "../middleware-common", version = "0.12.0" } -wasmer-clif-backend = { path = "../clif-backend", version = "0.12.0" } +wasmer-clif-backend = { path = "../clif-backend", version = "0.12.0", optional = true } wasmer-llvm-backend = { path = "../llvm-backend", version = "0.12.0", features = ["test"], optional = true } wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.12.0", optional = true } [features] -clif = [] +clif = ["wasmer-clif-backend"] llvm = ["wasmer-llvm-backend"] singlepass = ["wasmer-singlepass-backend"] diff --git a/lib/middleware-common-tests/src/lib.rs b/lib/middleware-common-tests/src/lib.rs index d6fe2644f..b2a99767e 100644 --- a/lib/middleware-common-tests/src/lib.rs +++ b/lib/middleware-common-tests/src/lib.rs @@ -3,27 +3,23 @@ mod tests { use wabt::wat2wasm; use wasmer_middleware_common::metering::*; - use wasmer_runtime_core::backend::RunnableModule; use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; + use wasmer_runtime_core::codegen::ModuleCodeGenerator; use wasmer_runtime_core::fault::{pop_code_version, push_code_version}; use wasmer_runtime_core::state::CodeVersion; use wasmer_runtime_core::{backend::Compiler, compile_with, imports, Func}; #[cfg(feature = "llvm")] - fn get_compiler(limit: u64) -> impl Compiler { - use wasmer_llvm_backend::ModuleCodeGenerator as LLVMMCG; - let c: StreamingCompiler = StreamingCompiler::new(move || { - let mut chain = MiddlewareChain::new(); - chain.push(Metering::new(limit)); - chain - }); - c - } + use wasmer_llvm_backend::ModuleCodeGenerator as MCG; #[cfg(feature = "singlepass")] + use wasmer_singlepass_backend::ModuleCodeGenerator as MCG; + + #[cfg(feature = "clif")] + compile_error!("cranelift does not implement metering yet"); + fn get_compiler(limit: u64) -> impl Compiler { - use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG; - let c: StreamingCompiler = StreamingCompiler::new(move || { + let c: StreamingCompiler = StreamingCompiler::new(move || { let mut chain = MiddlewareChain::new(); chain.push(Metering::new(limit)); chain @@ -34,13 +30,6 @@ mod tests { #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] compile_error!("compiler not specified, activate a compiler via features"); - #[cfg(feature = "clif")] - fn get_compiler(_limit: u64) -> impl Compiler { - compile_error!("cranelift does not implement metering"); - use wasmer_clif_backend::CraneliftCompiler; - CraneliftCompiler::new() - } - // Assemblyscript // export function add_to(x: i32, y: i32): i32 { // for(var i = 0; i < x; i++){ @@ -106,7 +95,7 @@ mod tests { let limit = 100u64; - let (compiler, backend_id) = get_compiler(limit); + let compiler = get_compiler(limit); let module = compile_with(&wasm_binary, &compiler).unwrap(); let import_object = imports! {}; @@ -121,8 +110,8 @@ mod tests { baseline: true, msm: msm, base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, + backend: MCG::backend_id(), runnable_module: instance.module.runnable_module.clone(), - backend: backend_id, }); true } else { @@ -148,7 +137,7 @@ mod tests { let limit = 100u64; - let (compiler, backend_id) = get_compiler(limit); + let compiler = get_compiler(limit); let module = compile_with(&wasm_binary, &compiler).unwrap(); let import_object = imports! {}; @@ -168,7 +157,7 @@ mod tests { baseline: true, msm: msm, base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, - backend: backend_id, + backend: MCG::backend_id(), runnable_module: instance.module.runnable_module.clone(), }); true