Handle test cases where roc_panic is dead-code eliminated

This commit is contained in:
Brian Carroll 2022-07-09 22:52:54 +01:00 committed by Folkert
parent 35dc65440c
commit 105fe0d456
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -13,14 +13,12 @@ use std::rc::Rc;
use std::sync::Mutex; use std::sync::Mutex;
use wasmer::WasmPtr; use wasmer::WasmPtr;
// Should manually match build.rs
const PLATFORM_FILENAME: &str = "wasm_test_platform";
const TEST_WRAPPER_NAME: &str = "test_wrapper"; const TEST_WRAPPER_NAME: &str = "test_wrapper";
const INIT_REFCOUNT_NAME: &str = "init_refcount_test"; const INIT_REFCOUNT_NAME: &str = "init_refcount_test";
macro_rules! host_bytes_path { macro_rules! host_bytes_path {
() => { () => {
// Should manually match build.rs. include_bytes! requires a string literal.
"../../build/wasm_test_platform.wasm" "../../build/wasm_test_platform.wasm"
}; };
} }
@ -215,17 +213,20 @@ where
let panic_msg_for_closure = panic_msg.clone(); let panic_msg_for_closure = panic_msg.clone();
module.link_wasi().unwrap(); module.link_wasi().unwrap();
module let try_link_panic = module.link_closure(
.link_closure( "env",
"env", "send_panic_msg_to_rust",
"send_panic_msg_to_rust", move |_call_context, args: (i32, i32)| {
move |_call_context, args: (i32, i32)| { let mut w = panic_msg_for_closure.lock().unwrap();
let mut w = panic_msg_for_closure.lock().unwrap(); *w = Some(args);
*w = Some(args); Ok(())
Ok(()) },
}, );
) match try_link_panic {
.expect("Unable to link roc_panic handler"); Ok(()) => {}
Err(wasm3::error::Error::FunctionNotFound) => {}
Err(e) => panic!("{:?}", e),
}
let test_wrapper = module let test_wrapper = module
.find_function::<(), i32>(TEST_WRAPPER_NAME) .find_function::<(), i32>(TEST_WRAPPER_NAME)