Skip to content

Commit

Permalink
tests/compilers: remove Engine configuration
Browse files Browse the repository at this point in the history
Since there's only one Engine now.
  • Loading branch information
epilys committed Jun 15, 2022
1 parent 746229c commit 0ec7e71
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 65 deletions.
43 changes: 9 additions & 34 deletions tests/compilers/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::sync::Arc;
use wasmer::{CompilerConfig, Engine as WasmerEngine, Features, ModuleMiddleware, Store};
use wasmer::{CompilerConfig, Engine, Features, ModuleMiddleware, Store};

#[derive(Clone, Debug, PartialEq)]
pub enum Compiler {
Expand All @@ -8,25 +8,18 @@ pub enum Compiler {
Singlepass,
}

#[derive(Clone, Debug, PartialEq)]
pub enum Engine {
Universal,
}

#[derive(Clone)]
pub struct Config {
pub compiler: Compiler,
pub engine: Engine,
pub features: Option<Features>,
pub middlewares: Vec<Arc<dyn ModuleMiddleware>>,
pub canonicalize_nans: bool,
}

impl Config {
pub fn new(engine: Engine, compiler: Compiler) -> Self {
pub fn new(compiler: Compiler) -> Self {
Self {
compiler,
engine,
features: None,
canonicalize_nans: false,
middlewares: vec![],
Expand Down Expand Up @@ -56,34 +49,16 @@ impl Config {
Store::new(&*engine)
}

pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Box<dyn WasmerEngine> {
match &self.engine {
#[cfg(feature = "universal")]
Engine::Universal => {
let mut engine = wasmer_compiler::Universal::new(compiler_config);
if let Some(ref features) = self.features {
engine = engine.features(features.clone())
}
Box::new(engine.engine())
}
#[allow(unreachable_patterns)]
engine => panic!(
"The {:?} Engine is not enabled. Please enable it using the features",
engine
),
pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Box<dyn Engine> {
let mut engine = wasmer_compiler::Universal::new(compiler_config);
if let Some(ref features) = self.features {
engine = engine.features(features.clone())
}
Box::new(engine.engine())
}

pub fn engine_headless(&self) -> Box<dyn WasmerEngine> {
match &self.engine {
#[cfg(feature = "universal")]
Engine::Universal => Box::new(wasmer_compiler::Universal::headless().engine()),
#[allow(unreachable_patterns)]
engine => panic!(
"The {:?} Engine is not enabled. Please enable it using the features",
engine
),
}
pub fn engine_headless(&self) -> Box<dyn Engine> {
Box::new(wasmer_compiler::Universal::headless().engine())
}

pub fn compiler_config(&self, canonicalize_nans: bool) -> Box<dyn CompilerConfig> {
Expand Down
2 changes: 1 addition & 1 deletion tests/compilers/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod traps;
mod wasi;
mod wast;

pub use crate::config::{Compiler, Config, Engine};
pub use crate::config::{Compiler, Config};
pub use crate::wasi::run_wasi;
pub use crate::wast::run_wast;
pub use wasmer_wast::WasiFileSystemKind;
12 changes: 0 additions & 12 deletions tests/compilers/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ pub fn run_wast(mut config: crate::Config, wast_path: &str) -> anyhow::Result<()
wast.allow_trap_message("uninitialized element 2", "uninitialized element");
// `liking.wast` has different wording but the same meaning
wast.allow_trap_message("out of bounds memory access", "memory out of bounds");
/*
if config.compiler == crate::Compiler::Cranelift && config.engine == crate::Engine::Dylib {
wast.allow_trap_message("call stack exhausted", "out of bounds memory access");
wast.allow_trap_message("indirect call type mismatch", "call stack exhausted");
wast.allow_trap_message("integer divide by zero", "call stack exhausted");
wast.allow_trap_message("integer overflow", "call stack exhausted");
wast.allow_trap_message("invalid conversion to integer", "call stack exhausted");
wast.allow_trap_message("undefined element", "call stack exhausted");
wast.allow_trap_message("uninitialized element", "call stack exhausted");
wast.allow_trap_message("unreachable", "call stack exhausted");
}
*/
if cfg!(feature = "coverage") {
wast.disable_assert_and_exhaustion();
}
Expand Down
13 changes: 0 additions & 13 deletions tests/integration/cli/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ impl Compiler {
}
}

#[derive(Debug, Copy, Clone)]
pub enum Engine {
Universal,
}

impl Engine {
pub const fn to_flag(self) -> &'static str {
match self {
Engine::Universal => "--universal",
}
}
}

pub fn run_code(
operating_dir: &Path,
executable_path: &Path,
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/compiler-test-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
engine_feature_name: &str|
-> ::proc_macro2::TokenStream {
let config_compiler = ::quote::format_ident!("{}", compiler_name);
let config_engine = ::quote::format_ident!("{}", engine_name);
let test_name = ::quote::format_ident!("{}", engine_name.to_lowercase());
let mut new_sig = func.sig.clone();
let attrs = func
Expand All @@ -89,7 +88,7 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
#attrs
#[cfg(feature = #engine_feature_name)]
#new_sig {
#fn_name(crate::Config::new(crate::Engine::#config_engine, crate::Compiler::#config_compiler))
#fn_name(crate::Config::new(crate::Compiler::#config_compiler))
}
};
if should_ignore(
Expand Down
3 changes: 0 additions & 3 deletions tests/lib/compiler-test-derive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ gen_tests! {
#[cfg(feature = "universal")]
fn universal() {
foo(crate::Config::new(
crate::Engine::Universal,
crate::Compiler::Singlepass
))
}
Expand All @@ -73,7 +72,6 @@ gen_tests! {
#[cfg(feature = "universal")]
fn universal() {
foo(crate::Config::new(
crate::Engine::Universal,
crate::Compiler::Cranelift
))
}
Expand All @@ -87,7 +85,6 @@ gen_tests! {
#[cfg(feature = "universal")]
fn universal() {
foo(crate::Config::new(
crate::Engine::Universal,
crate::Compiler::LLVM
))
}
Expand Down

0 comments on commit 0ec7e71

Please sign in to comment.