diff --git a/crates/common/src/result.rs b/crates/common/src/result.rs index 69e34f8f..5279f9ed 100644 --- a/crates/common/src/result.rs +++ b/crates/common/src/result.rs @@ -189,3 +189,47 @@ impl From<&str> for WasmErrorInner { s.to_string().into() } } + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + #[cfg(not(feature = "error_as_host"))] + fn wasm_error_macro_guest() { + assert_eq!( + wasm_error!("foo").error, + WasmErrorInner::Guest("foo".into()), + ); + + assert_eq!( + wasm_error!("{} {}", "foo", "bar").error, + WasmErrorInner::Guest("foo bar".into()) + ); + + assert_eq!( + wasm_error!(WasmErrorInner::Host("foo".into())).error, + WasmErrorInner::Host("foo".into()), + ); + } + + #[test] + #[cfg(feature = "error_as_host")] + fn wasm_error_macro_host() { + assert_eq!( + wasm_error!("foo").error, + WasmErrorInner::Host("foo".into()), + ); + + assert_eq!( + wasm_error!("{} {}", "foo", "bar").error, + WasmErrorInner::Host("foo bar".into()) + ); + + assert_eq!( + wasm_error!(WasmErrorInner::Guest("foo".into())).error, + WasmErrorInner::Guest("foo".into()), + ); + } +} diff --git a/crates/host/src/guest.rs b/crates/host/src/guest.rs index 5279a236..57228728 100644 --- a/crates/host/src/guest.rs +++ b/crates/host/src/guest.rs @@ -261,26 +261,3 @@ where return_value.map_err(|e| WasmHostError(e).into()) } - -#[cfg(test)] -pub mod tests { - use super::*; - - #[test] - fn wasm_error_macro_host() { - assert_eq!( - wasm_error!("foo").0.error, - WasmErrorInner::Host("foo".into()), - ); - - assert_eq!( - wasm_error!("{} {}", "foo", "bar").0.error, - WasmErrorInner::Host("foo bar".into()) - ); - - assert_eq!( - wasm_error!(WasmErrorInner::Host("foo".into())).0.error, - WasmErrorInner::Host("foo".into()), - ); - } -} diff --git a/scripts/test-wasmer_sys_dev.sh b/scripts/test-wasmer_sys_dev.sh index d0a2969a..fbe1c755 100755 --- a/scripts/test-wasmer_sys_dev.sh +++ b/scripts/test-wasmer_sys_dev.sh @@ -13,6 +13,9 @@ cargo clippy -- --deny warnings cargo build --release -p test_wasm_core --target wasm32-unknown-unknown # tests the root workspace +cargo test --no-default-features --features wasmer_sys_dev ${1-} -- --nocapture + +# tests the root workspace, error_as_host cargo test --no-default-features --features error_as_host,wasmer_sys_dev ${1-} -- --nocapture # build wasm and run the "full" tests for wasmer_sys_dev diff --git a/scripts/test-wasmer_sys_prod.sh b/scripts/test-wasmer_sys_prod.sh index 9c68fad5..54ae3d69 100755 --- a/scripts/test-wasmer_sys_prod.sh +++ b/scripts/test-wasmer_sys_prod.sh @@ -5,6 +5,9 @@ export RUST_BACKTRACE=full export WASMER_BACKTRACE=1 # tests the root workspace +cargo test --no-default-features --features wasmer_sys_prod ${1-} -- --nocapture + +# tests the root workspace, error_as_host cargo test --no-default-features --features error_as_host,wasmer_sys_prod ${1-} -- --nocapture # build wasm and run the "full" tests for wasmer_sys_prod diff --git a/scripts/test-wasmer_wamr.sh b/scripts/test-wasmer_wamr.sh index d52c8660..8c713bb0 100755 --- a/scripts/test-wasmer_wamr.sh +++ b/scripts/test-wasmer_wamr.sh @@ -6,6 +6,9 @@ export WASMER_BACKTRACE=1 # tests the root workspace +cargo test --no-default-features --features wasmer_wamr ${1-} -- --nocapture + +# tests the root workspace, error_as_host cargo test --no-default-features --features error_as_host,wasmer_wamr ${1-} -- --nocapture # build wasm and run the "full" tests for wasmer_wamr