diff --git a/cli/tests/cli_run.rs b/cli/tests/cli_run.rs index a9e87a8a01..c8b97ded57 100644 --- a/cli/tests/cli_run.rs +++ b/cli/tests/cli_run.rs @@ -164,12 +164,12 @@ mod cli_run { #[test] #[serial(multi_dep_str)] - fn run_multi_dep_str() { - if true { - todo!( - "fix this test so it no longer deadlocks and hangs during monomorphization! The test never shows the error; to see the panic error, run this: cargo run run cli/tests/fixtures/multi-dep-str/Main.roc" - ); - } + fn run_multi_dep_str_unoptimized() { + // if true { + // todo!( + // "fix this test so it no longer deadlocks and hangs during monomorphization! The test never shows the error; to see the panic error, run this: cargo run run cli/tests/fixtures/multi-dep-str/Main.roc" + // ); + // } check_output( &fixture_file("multi-dep-str", "Main.roc"), @@ -198,7 +198,7 @@ mod cli_run { #[test] #[serial(multi_dep_thunk)] - fn run_multi_dep_thunk() { + fn run_multi_dep_thunk_unoptimized() { check_output( &fixture_file("multi-dep-thunk", "Main.roc"), &[], diff --git a/cli/tests/fixtures/multi-dep-str/platform/Cargo.toml b/cli/tests/fixtures/multi-dep-str/platform/Cargo.toml index 70f3c1f86c..cb6b8f317e 100644 --- a/cli/tests/fixtures/multi-dep-str/platform/Cargo.toml +++ b/cli/tests/fixtures/multi-dep-str/platform/Cargo.toml @@ -8,6 +8,6 @@ edition = "2018" crate-type = ["staticlib"] [dependencies] -roc_std = { path = "../../../roc_std" } +roc_std = { path = "../../../../../roc_std" } [workspace] diff --git a/cli/tests/fixtures/multi-dep-str/platform/src/lib.rs b/cli/tests/fixtures/multi-dep-str/platform/src/lib.rs index 07375c7b46..2f1dbfb854 100644 --- a/cli/tests/fixtures/multi-dep-str/platform/src/lib.rs +++ b/cli/tests/fixtures/multi-dep-str/platform/src/lib.rs @@ -1,17 +1,27 @@ +use roc_std::RocCallResult; use roc_std::RocStr; use std::str; extern "C" { - #[link_name = "main_1"] - fn main() -> RocStr; + #[link_name = "main_1_exposed"] + fn say_hello(output: &mut RocCallResult) -> (); } #[no_mangle] pub fn rust_main() -> isize { - println!( - "Roc says: {}", - str::from_utf8(unsafe { main().as_slice() }).unwrap() - ); + let answer = unsafe { + use std::mem::MaybeUninit; + let mut output: MaybeUninit> = MaybeUninit::uninit(); + + say_hello(&mut *output.as_mut_ptr()); + + match output.assume_init().into() { + Ok(value) => value, + Err(msg) => panic!("roc failed with message {}", msg), + } + }; + + println!("Roc says: {}", str::from_utf8(answer.as_slice()).unwrap()); // Exit code 0 diff --git a/cli/tests/fixtures/multi-dep-thunk/platform/Cargo.toml b/cli/tests/fixtures/multi-dep-thunk/platform/Cargo.toml index 70f3c1f86c..cb6b8f317e 100644 --- a/cli/tests/fixtures/multi-dep-thunk/platform/Cargo.toml +++ b/cli/tests/fixtures/multi-dep-thunk/platform/Cargo.toml @@ -8,6 +8,6 @@ edition = "2018" crate-type = ["staticlib"] [dependencies] -roc_std = { path = "../../../roc_std" } +roc_std = { path = "../../../../../roc_std" } [workspace] diff --git a/cli/tests/fixtures/multi-dep-thunk/platform/src/lib.rs b/cli/tests/fixtures/multi-dep-thunk/platform/src/lib.rs index 07375c7b46..2f1dbfb854 100644 --- a/cli/tests/fixtures/multi-dep-thunk/platform/src/lib.rs +++ b/cli/tests/fixtures/multi-dep-thunk/platform/src/lib.rs @@ -1,17 +1,27 @@ +use roc_std::RocCallResult; use roc_std::RocStr; use std::str; extern "C" { - #[link_name = "main_1"] - fn main() -> RocStr; + #[link_name = "main_1_exposed"] + fn say_hello(output: &mut RocCallResult) -> (); } #[no_mangle] pub fn rust_main() -> isize { - println!( - "Roc says: {}", - str::from_utf8(unsafe { main().as_slice() }).unwrap() - ); + let answer = unsafe { + use std::mem::MaybeUninit; + let mut output: MaybeUninit> = MaybeUninit::uninit(); + + say_hello(&mut *output.as_mut_ptr()); + + match output.assume_init().into() { + Ok(value) => value, + Err(msg) => panic!("roc failed with message {}", msg), + } + }; + + println!("Roc says: {}", str::from_utf8(answer.as_slice()).unwrap()); // Exit code 0