mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
fix emscripten tests
This commit is contained in:
parent
5993c0bcae
commit
6d494a297f
@ -25,5 +25,4 @@ glob = "0.2.11"
|
|||||||
[features]
|
[features]
|
||||||
clif = []
|
clif = []
|
||||||
llvm = ["wasmer-llvm-backend"]
|
llvm = ["wasmer-llvm-backend"]
|
||||||
singlepass = ["wasmer-singlepass-backend"]
|
singlepass = ["wasmer-singlepass-backend"]
|
||||||
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
|
|
@ -1 +1,53 @@
|
|||||||
// nothing to see here
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::sync::Arc;
|
||||||
|
use wabt::wat2wasm;
|
||||||
|
use wasmer_emscripten::is_emscripten_module;
|
||||||
|
use wasmer_runtime_core::backend::Compiler;
|
||||||
|
use wasmer_runtime_core::compile_with;
|
||||||
|
|
||||||
|
#[cfg(feature = "clif")]
|
||||||
|
fn get_compiler() -> impl Compiler {
|
||||||
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
|
CraneliftCompiler::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "llvm")]
|
||||||
|
fn get_compiler() -> impl Compiler {
|
||||||
|
use wasmer_llvm_backend::LLVMCompiler;
|
||||||
|
LLVMCompiler::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "singlepass")]
|
||||||
|
fn get_compiler() -> impl Compiler {
|
||||||
|
use wasmer_singlepass_backend::SinglePassCompiler;
|
||||||
|
SinglePassCompiler::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
|
||||||
|
fn get_compiler() -> impl Compiler {
|
||||||
|
panic!("compiler not specified, activate a compiler via features");
|
||||||
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
|
CraneliftCompiler::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_detect_emscripten_files() {
|
||||||
|
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_true.wast");
|
||||||
|
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
||||||
|
let module =
|
||||||
|
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
|
||||||
|
let module = Arc::new(module);
|
||||||
|
assert!(is_emscripten_module(&module));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_detect_non_emscripten_files() {
|
||||||
|
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_false.wast");
|
||||||
|
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
||||||
|
let module =
|
||||||
|
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
|
||||||
|
let module = Arc::new(module);
|
||||||
|
assert!(!is_emscripten_module(&module));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,4 +16,7 @@ time = "0.1.41"
|
|||||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.4" }
|
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.4" }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
rand = "0.6"
|
rand = "0.6"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
debug = ["wasmer-runtime-core/debug"]
|
@ -263,57 +263,3 @@ pub fn get_current_directory(ctx: &mut Ctx) -> Option<PathBuf> {
|
|||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::is_emscripten_module;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use wabt::wat2wasm;
|
|
||||||
use wasmer_runtime_core::backend::Compiler;
|
|
||||||
use wasmer_runtime_core::compile_with;
|
|
||||||
|
|
||||||
#[cfg(feature = "clif")]
|
|
||||||
fn get_compiler() -> impl Compiler {
|
|
||||||
use wasmer_clif_backend::CraneliftCompiler;
|
|
||||||
CraneliftCompiler::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "llvm")]
|
|
||||||
fn get_compiler() -> impl Compiler {
|
|
||||||
use wasmer_llvm_backend::LLVMCompiler;
|
|
||||||
LLVMCompiler::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "singlepass")]
|
|
||||||
fn get_compiler() -> impl Compiler {
|
|
||||||
use wasmer_singlepass_backend::SinglePassCompiler;
|
|
||||||
SinglePassCompiler::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
|
|
||||||
fn get_compiler() -> impl Compiler {
|
|
||||||
panic!("compiler not specified, activate a compiler via features");
|
|
||||||
use wasmer_clif_backend::CraneliftCompiler;
|
|
||||||
CraneliftCompiler::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_detect_emscripten_files() {
|
|
||||||
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_true.wast");
|
|
||||||
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
|
||||||
let module =
|
|
||||||
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
|
|
||||||
let module = Arc::new(module);
|
|
||||||
assert!(is_emscripten_module(&module));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_detect_non_emscripten_files() {
|
|
||||||
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_false.wast");
|
|
||||||
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
|
||||||
let module =
|
|
||||||
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
|
|
||||||
let module = Arc::new(module);
|
|
||||||
assert!(!is_emscripten_module(&module));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user