Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 2ed1686

Browse files
committed
Update WIT in tests with async
This commit updates the WIT used in test to use the `async` keyword and generally try to avoid manually configuring what's async and what's not in the guest. This does not update the host's handling of the `async` keyword in WIT for `wasmtime::component::bindgen!`. Some assorted bindgen issues were fixed here and there and WASI WITs were updated as well with `async` where it seemed appropriate. I'll note that there are some usages of concurrent imports when there's no actual concurrency, it's just there for getting an `Accessor` and, for example, spawning tasks. In these situations we may want to explore possible modes of bindings generation on the host side of things which avoids the need for manual configuration. Coupled with bytecodealliance/wit-bindgen#1278 and bytecodealliance/wit-bindgen#1279.
1 parent e503821 commit 2ed1686

55 files changed

Lines changed: 299 additions & 540 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 97 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,9 @@ wit-component = { git = "https://github.com/bytecodealliance/wasm-tools" }
608608
wasm-wave = { git = "https://github.com/bytecodealliance/wasm-tools" }
609609
wasm-compose = { git = "https://github.com/bytecodealliance/wasm-tools" }
610610
wasm-metadata = { git = "https://github.com/bytecodealliance/wasm-tools" }
611-
wit-bindgen = { git = "https://github.com/bytecodealliance/witx-bindgen" }
612-
wit-bindgen-rt = { git = "https://github.com/bytecodealliance/witx-bindgen" }
613-
wit-bindgen-rust-macro = { git = "https://github.com/bytecodealliance/witx-bindgen" }
611+
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen" }
612+
wit-bindgen-rt = { git = "https://github.com/bytecodealliance/wit-bindgen" }
613+
wit-bindgen-rust-macro = { git = "https://github.com/bytecodealliance/wit-bindgen" }
614614

615615
# wasmparser = { path = '../wasm-tools/crates/wasmparser' }
616616
# wat = { path = '../wasm-tools/crates/wat' }

crates/misc/component-async-tests/http/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ wasmtime::component::bindgen!({
1313
"wasi:http/types@0.3.0-draft#[constructor]body",
1414
"wasi:http/types@0.3.0-draft#[static]body.new-with-trailers",
1515
"wasi:http/types@0.3.0-draft#[static]body.finish",
16-
"wasi:http/handler@0.3.0-draft#handle",
16+
"wasi:http/handler@0.3.0-draft#[async]handle",
1717
]
1818
},
1919
with: {

crates/misc/component-async-tests/src/sleep.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ wasmtime::component::bindgen!({
1010
concurrent_exports: true,
1111
async: {
1212
only_imports: [
13-
"local:local/sleep#sleep-millis",
13+
"local:local/sleep#[async]sleep-millis",
1414
]
1515
},
1616
});

crates/misc/component-async-tests/src/yield_host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub mod bindings {
1414
concurrent_exports: true,
1515
async: {
1616
only_imports: [
17-
"local:local/ready#when-ready",
17+
"local:local/ready#[async]when-ready",
1818
]
1919
},
2020
});

crates/misc/component-async-tests/tests/scenario/round_trip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub async fn test_round_trip(component: &[u8], inputs_and_outputs: &[(&str, &str
347347
linker
348348
.root()
349349
.instance("local:local/baz")?
350-
.func_new_concurrent("foo", |_, params| {
350+
.func_new_concurrent("[async]foo", |_, params| {
351351
Box::pin(async move {
352352
tokio::time::sleep(Duration::from_millis(10)).await;
353353
let Some(Val::String(s)) = params.into_iter().next() else {
@@ -366,7 +366,7 @@ pub async fn test_round_trip(component: &[u8], inputs_and_outputs: &[(&str, &str
366366
.get_export_index(&mut store, None, "local:local/baz")
367367
.ok_or_else(|| anyhow!("can't find `local:local/baz` in instance"))?;
368368
let foo_function = instance
369-
.get_export_index(&mut store, Some(&baz_instance), "foo")
369+
.get_export_index(&mut store, Some(&baz_instance), "[async]foo")
370370
.ok_or_else(|| anyhow!("can't find `foo` in instance"))?;
371371
let foo_function = instance
372372
.get_func(&mut store, foo_function)

crates/misc/component-async-tests/tests/scenario/round_trip_many.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ async fn test_round_trip_many(component: &[u8], inputs_and_outputs: &[(&str, &st
306306
linker
307307
.root()
308308
.instance("local:local/many")?
309-
.func_new_concurrent("foo", |_, params| {
309+
.func_new_concurrent("[async]foo", |_, params| {
310310
Box::pin(async move {
311311
tokio::time::sleep(Duration::from_millis(10)).await;
312312
let mut params = params.into_iter();
@@ -328,7 +328,7 @@ async fn test_round_trip_many(component: &[u8], inputs_and_outputs: &[(&str, &st
328328
.get_export_index(&mut store, None, "local:local/many")
329329
.ok_or_else(|| anyhow!("can't find `local:local/many` in instance"))?;
330330
let foo_function = instance
331-
.get_export_index(&mut store, Some(&baz_instance), "foo")
331+
.get_export_index(&mut store, Some(&baz_instance), "[async]foo")
332332
.ok_or_else(|| anyhow!("can't find `foo` in instance"))?;
333333
let foo_function = instance
334334
.get_func(&mut store, foo_function)

crates/misc/component-async-tests/tests/scenario/transmit.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ impl TransmitTest for DynamicTransmitTest {
241241
.get_export_index(store.as_context_mut(), None, "local:local/transmit")
242242
.ok_or_else(|| anyhow!("can't find `local:local/transmit` in instance"))?;
243243
let exchange_function = instance
244-
.get_export_index(store.as_context_mut(), Some(&transmit_instance), "exchange")
244+
.get_export_index(
245+
store.as_context_mut(),
246+
Some(&transmit_instance),
247+
"[async]exchange",
248+
)
245249
.ok_or_else(|| anyhow!("can't find `exchange` in instance"))?;
246250
instance
247251
.get_func(store.as_context_mut(), exchange_function)

0 commit comments

Comments
 (0)