1- #![ cfg( feature = "p3" ) ]
2-
31use std:: path:: Path ;
42
53use anyhow:: { Context as _, anyhow} ;
@@ -19,26 +17,28 @@ macro_rules! assert_test_exists {
1917}
2018
2119struct Ctx {
22- ctx : WasiCtx ,
20+ table : ResourceTable ,
21+ p2 : wasmtime_wasi:: p2:: WasiCtx ,
22+ p3 : WasiCtx ,
2323}
2424
2525impl 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`
3232impl 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`
3939impl 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
8789foreach_p3 ! ( assert_test_exists) ;
8890
89- #[ ignore = "not yet implemented" ]
9091#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
9192async 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" ) ) ]
9797async fn p3_random_imports ( ) -> anyhow:: Result < ( ) > {
9898 run ( P3_RANDOM_IMPORTS_COMPONENT ) . await
0 commit comments