2019-01-11 05:37:59 +00:00
|
|
|
macro_rules! assert_emscripten_output {
|
|
|
|
($file:expr, $name:expr, $args:expr, $expected:expr) => {{
|
2019-01-18 00:25:05 +00:00
|
|
|
// TODO: Cyclic Dep!
|
|
|
|
use wasmer::{
|
|
|
|
webassembly::{
|
|
|
|
compile,
|
|
|
|
start_instance,
|
|
|
|
},
|
|
|
|
common::stdio::StdioCapturer,
|
|
|
|
};
|
|
|
|
|
|
|
|
use wasmer_runtime::{
|
|
|
|
instance::Instance,
|
|
|
|
module::Module,
|
|
|
|
table::TableBacking
|
|
|
|
};
|
|
|
|
|
2019-01-11 05:37:59 +00:00
|
|
|
use wasmer_clif_backend::CraneliftCompiler;
|
2019-01-18 00:25:05 +00:00
|
|
|
use wasmer_emscripten::{
|
|
|
|
EmscriptenGlobals,
|
|
|
|
generate_emscripten_env,
|
|
|
|
};
|
2019-01-11 05:37:59 +00:00
|
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
let wasm_bytes = include_bytes!($file);
|
2019-01-18 00:25:05 +00:00
|
|
|
|
|
|
|
let module = compile(&wasm_bytes[..])
|
|
|
|
.map_err(|err| format!("Can't create the WebAssembly module: {}", err)).unwrap(); // NOTE: Need to figure what the unwrap is for ??
|
|
|
|
|
|
|
|
let emscripten_globals = EmscriptenGlobals::new();
|
|
|
|
let mut import_object = generate_emscripten_env(&emscripten_globals);
|
|
|
|
|
|
|
|
let mut instance = module.instantiate(import_object)
|
|
|
|
.map_err(|err| format!("Can't instantiate the WebAssembly module: {}", err)).unwrap(); // NOTE: Need to figure what the unwrap is for ??
|
|
|
|
|
|
|
|
start_instance(
|
|
|
|
Arc::clone(&module),
|
|
|
|
&mut instance,
|
|
|
|
$name,
|
|
|
|
$args,
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(false, "Emscripten tests are mocked");
|
2019-01-11 05:37:59 +00:00
|
|
|
|
|
|
|
// let capturer = StdioCapturer::new();
|
|
|
|
// start_instance(
|
|
|
|
// Arc::clone(&result_object.module),
|
|
|
|
// &mut result_object.instance,
|
|
|
|
// $name,
|
|
|
|
// $args,
|
|
|
|
// )
|
|
|
|
// .unwrap();
|
|
|
|
// let output = capturer.end().unwrap().0;
|
|
|
|
// let expected_output = include_str!($expected);
|
2019-01-18 00:25:05 +00:00
|
|
|
// assert!(false, "Emscripten tests are mocked");
|
2019-01-11 05:37:59 +00:00
|
|
|
// assert!(
|
|
|
|
// output.contains(expected_output),
|
|
|
|
// "Output: `{}` does not contain expected output: `{}`",
|
|
|
|
// output,
|
|
|
|
// expected_output
|
|
|
|
// );
|
|
|
|
}};
|
|
|
|
}
|