Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Add `--async[=true|false]` flag to `wast` CLI (#11953)

Alex Crichton23b9f3b0b71a
diff --git a/crates/fuzzing/src/oracles.rs b/crates/fuzzing/src/oracles.rs
index 3ab12c1b05..7afc5fcf84 100644
--- a/crates/fuzzing/src/oracles.rs
+++ b/crates/fuzzing/src/oracles.rs
@@ -758,6 +758,7 @@ pub fn wast_test(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<()> {
} else {
wasmtime_wast::Async::Yes
};
+ log::debug!("async: {async_:?}");
let engine = Engine::new(&fuzz_config.to_wasmtime()).unwrap();
let mut wast_context = WastContext::new(&engine, async_, move |store| {
fuzz_config.configure_store_epoch_and_fuel(store);
diff --git a/crates/wast/src/wast.rs b/crates/wast/src/wast.rs
index 0b4dae88eb..97e0b84be3 100644
--- a/crates/wast/src/wast.rs
+++ b/crates/wast/src/wast.rs
@@ -92,7 +92,7 @@ enum Export<'a> {
/// Whether or not to use async APIs when calling wasm during wast testing.
///
/// Passed to [`WastContext::new`].
-#[derive(Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq)]
#[expect(missing_docs, reason = "self-describing variants")]
pub enum Async {
Yes,
diff --git a/src/commands/wast.rs b/src/commands/wast.rs
index 2e84b83e3f..e136987f74 100644
--- a/src/commands/wast.rs
+++ b/src/commands/wast.rs
@@ -31,6 +31,13 @@ pub struct WastCommand {
/// compiling natively.
#[arg(long)]
precompile_load: Option<PathBuf>,
+
+ /// Whether or not to run wasm in async mode.
+ ///
+ /// This is enabled by default but disabling it may be useful when testing
+ /// Wasmtime itself.
+ #[arg(long = "async", require_equals = true, value_name = "true|false")]
+ async_: Option<Option<bool>>,
}
impl WastCommand {
@@ -38,18 +45,27 @@ impl WastCommand {
pub fn execute(mut self) -> Result<()> {
self.common.init_logging()?;
+ let async_ = optional_flag_with_default(self.async_, true);
let mut config = self.common.config(None)?;
- config.async_support(true);
+ config.async_support(async_);
let engine = Engine::new(&config)?;
- let mut wast_context = WastContext::new(&engine, wasmtime_wast::Async::Yes, move |store| {
- if let Some(fuel) = self.common.wasm.fuel {
- store.set_fuel(fuel).unwrap();
- }
- if let Some(true) = self.common.wasm.epoch_interruption {
- store.epoch_deadline_trap();
- store.set_epoch_deadline(1);
- }
- });
+ let mut wast_context = WastContext::new(
+ &engine,
+ if async_ {
+ wasmtime_wast::Async::Yes
+ } else {
+ wasmtime_wast::Async::No
+ },
+ move |store| {
+ if let Some(fuel) = self.common.wasm.fuel {
+ store.set_fuel(fuel).unwrap();
+ }
+ if let Some(true) = self.common.wasm.epoch_interruption {
+ store.epoch_deadline_trap();
+ store.set_epoch_deadline(1);
+ }
+ },
+ );
wast_context.generate_dwarf(optional_flag_with_default(self.generate_dwarf, true));
wast_context