mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Handle test cases where roc_panic is dead-code eliminated
This commit is contained in:
parent
35dc65440c
commit
105fe0d456
1 changed files with 15 additions and 14 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue