A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
run task to completion in `wasmtime run --invoke 'foo()'` (#12304)
Joel Diceba594ece84fe
diff --git a/src/commands/run.rs b/src/commands/run.rsindex f0af90bc42..13989e76ea 100644--- a/src/commands/run.rs+++ b/src/commands/run.rs@@ -616,8 +616,22 @@ impl RunCommand {.expect("found export index");let mut results = vec![Val::Bool(false); func_type.results().len()];- func.call_async(&mut *store, ¶ms, &mut results).await?;- func.post_return_async(&mut *store).await?;++ #[cfg(feature = "component-model-async")]+ {+ store+ .run_concurrent(async |store| {+ let task = func.call_concurrent(store, ¶ms, &mut results).await?;+ task.block(store).await;+ anyhow::Ok(())+ })+ .await??;+ }+ #[cfg(not(feature = "component-model-async"))]+ {+ func.call_async(&mut *store, ¶ms, &mut results).await?;+ func.post_return_async(&mut *store).await?;+ }println!("{}", DisplayFuncResults(&results));diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rsindex 9e2f063067..79d76cd38a 100644--- a/tests/all/cli_tests.rs+++ b/tests/all/cli_tests.rs@@ -2182,6 +2182,25 @@ start a print 1234Ok(())}+ #[test]+ fn p2_cli_p3_hello_stdout_post_return_invoke() -> Result<()> {+ let output = run_wasmtime(&[+ "run",+ "-Wcomponent-model-async",+ "-Sp3",+ "--invoke",+ "run()",+ P3_CLI_HELLO_STDOUT_POST_RETURN_COMPONENT,+ ]);+ if cfg!(feature = "component-model-async") {+ let output = output?;+ assert_eq!(output, "hello, world\nhello again, after return\nok\n");+ } else {+ assert!(output.is_err());+ }+ Ok(())+ }+mod invoke {use super::*;