wiggle: expand test suite

sync test: show the dummy executor will trap (rather than panic) when a
future inside it pends.

async test: show that the executor is hooked up to a future that pends
for a trivial amount of time.

this adds tokio to the dev-dependencies of wiggle, it shouldn't end up
increasing the build burden for the project as a whole since its already
a dev-dependency.
This commit is contained in:
Pat Hickey
2021-07-16 09:31:37 -07:00
parent 6f07c76c84
commit 4fa4a72328
5 changed files with 74 additions and 51 deletions

View File

@@ -933,7 +933,10 @@ impl From<GuestError> for Trap {
}
}
pub fn run_in_dummy_executor<F: std::future::Future>(future: F) -> Result<F::Output, Trap> {
#[cfg(feature = "wasmtime")]
pub fn run_in_dummy_executor<F: std::future::Future>(
future: F,
) -> Result<F::Output, wasmtime_crate::Trap> {
use std::pin::Pin;
use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
@@ -943,7 +946,7 @@ pub fn run_in_dummy_executor<F: std::future::Future>(future: F) -> Result<F::Out
match f.as_mut().poll(&mut cx) {
Poll::Ready(val) => return Ok(val),
Poll::Pending =>
return Err(Trap::String("Cannot wait on pending future: must enable wiggle \"async\" future and execute on an async Store".to_owned()))
return Err(wasmtime_crate::Trap::new("Cannot wait on pending future: must enable wiggle \"async\" future and execute on an async Store"))
}
fn dummy_waker() -> Waker {