Skip to content

Commit 3444f1d

Browse files
committed
test(wasip3): link wasip2
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 6dae78e commit 3444f1d

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

  • crates/wasi/tests/all/p3

crates/wasi/tests/all/p3/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(feature = "p3")]
2-
31
use std::path::Path;
42

53
use anyhow::{Context as _, anyhow};
@@ -19,26 +17,28 @@ macro_rules! assert_test_exists {
1917
}
2018

2119
struct Ctx {
22-
ctx: WasiCtx,
20+
table: ResourceTable,
21+
p2: wasmtime_wasi::p2::WasiCtx,
22+
p3: WasiCtx,
2323
}
2424

2525
impl WasiView for Ctx {
2626
fn ctx(&mut self) -> &mut WasiCtx {
27-
&mut self.ctx
27+
&mut self.p3
2828
}
2929
}
3030

3131
// TODO: Remove once test components are not built for `wasm32-wasip1`
3232
impl wasmtime_wasi::p2::WasiView for Ctx {
3333
fn ctx(&mut self) -> &mut wasmtime_wasi::p2::WasiCtx {
34-
panic!("should not use wasip2")
34+
&mut self.p2
3535
}
3636
}
3737

3838
// TODO: Remove once test components are not built for `wasm32-wasip1`
3939
impl wasmtime_wasi::p2::IoView for Ctx {
4040
fn table(&mut self) -> &mut ResourceTable {
41-
panic!("should not use wasip2")
41+
&mut self.table
4242
}
4343
}
4444

@@ -70,8 +70,10 @@ async fn run(path: &str) -> anyhow::Result<()> {
7070
for (var, val) in test_programs_artifacts::wasi_tests_environment() {
7171
builder.env(var, val);
7272
}
73-
let ctx = builder.build();
74-
let mut store = Store::new(&engine, Ctx { ctx });
73+
let table = ResourceTable::default();
74+
let p2 = wasmtime_wasi::p2::WasiCtx::builder().build();
75+
let p3 = builder.build();
76+
let mut store = Store::new(&engine, Ctx { table, p2, p3 });
7577
let instance = linker.instantiate_async(&mut store, &component).await?;
7678
let command =
7779
Command::new(&mut store, &instance).context("failed to instantiate `wasi:cli/command`")?;
@@ -86,13 +88,11 @@ async fn run(path: &str) -> anyhow::Result<()> {
8688

8789
foreach_p3!(assert_test_exists);
8890

89-
#[ignore = "not yet implemented"]
9091
#[test_log::test(tokio::test(flavor = "multi_thread"))]
9192
async fn p3_clocks_sleep() -> anyhow::Result<()> {
9293
run(P3_CLOCKS_SLEEP_COMPONENT).await
9394
}
9495

95-
#[ignore = "not yet implemented"]
9696
#[test_log::test(tokio::test(flavor = "multi_thread"))]
9797
async fn p3_random_imports() -> anyhow::Result<()> {
9898
run(P3_RANDOM_IMPORTS_COMPONENT).await

0 commit comments

Comments
 (0)