@@ -8,7 +8,7 @@ use wasmtime::{
8
8
use wasmtime_wasi:: preview2:: {
9
9
command:: { add_to_linker, Command } ,
10
10
pipe:: MemoryInputPipe ,
11
- DirPerms , FilePerms , HostMonotonicClock , HostWallClock , IsATTY , Table , WasiCtx , WasiCtxBuilder ,
11
+ DirPerms , FilePerms , HostMonotonicClock , HostWallClock , Table , WasiCtx , WasiCtxBuilder ,
12
12
WasiView ,
13
13
} ;
14
14
@@ -61,10 +61,10 @@ async fn instantiate(
61
61
62
62
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
63
63
async fn hello_stdout ( ) -> Result < ( ) > {
64
- let mut table = Table :: new ( ) ;
64
+ let table = Table :: new ( ) ;
65
65
let wasi = WasiCtxBuilder :: new ( )
66
66
. args ( & [ "gussie" , "sparky" , "willa" ] )
67
- . build ( & mut table ) ? ;
67
+ . build ( ) ;
68
68
let ( mut store, command) =
69
69
instantiate ( get_component ( "hello_stdout" ) , CommandCtx { table, wasi } ) . await ?;
70
70
command
@@ -76,7 +76,7 @@ async fn hello_stdout() -> Result<()> {
76
76
77
77
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
78
78
async fn panic ( ) -> Result < ( ) > {
79
- let mut table = Table :: new ( ) ;
79
+ let table = Table :: new ( ) ;
80
80
let wasi = WasiCtxBuilder :: new ( )
81
81
. args ( & [
82
82
"diesel" ,
@@ -88,7 +88,7 @@ async fn panic() -> Result<()> {
88
88
"good" ,
89
89
"yesterday" ,
90
90
] )
91
- . build ( & mut table ) ? ;
91
+ . build ( ) ;
92
92
let ( mut store, command) =
93
93
instantiate ( get_component ( "panic" ) , CommandCtx { table, wasi } ) . await ?;
94
94
let r = command. wasi_cli_run ( ) . call_run ( & mut store) . await ;
@@ -99,10 +99,10 @@ async fn panic() -> Result<()> {
99
99
100
100
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
101
101
async fn args ( ) -> Result < ( ) > {
102
- let mut table = Table :: new ( ) ;
102
+ let table = Table :: new ( ) ;
103
103
let wasi = WasiCtxBuilder :: new ( )
104
104
. args ( & [ "hello" , "this" , "" , "is an argument" , "with 🚩 emoji" ] )
105
- . build ( & mut table ) ? ;
105
+ . build ( ) ;
106
106
let ( mut store, command) =
107
107
instantiate ( get_component ( "args" ) , CommandCtx { table, wasi } ) . await ?;
108
108
command
@@ -114,8 +114,8 @@ async fn args() -> Result<()> {
114
114
115
115
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
116
116
async fn random ( ) -> Result < ( ) > {
117
- let mut table = Table :: new ( ) ;
118
- let wasi = WasiCtxBuilder :: new ( ) . build ( & mut table ) ? ;
117
+ let table = Table :: new ( ) ;
118
+ let wasi = WasiCtxBuilder :: new ( ) . build ( ) ;
119
119
let ( mut store, command) =
120
120
instantiate ( get_component ( "random" ) , CommandCtx { table, wasi } ) . await ?;
121
121
@@ -157,11 +157,11 @@ async fn time() -> Result<()> {
157
157
}
158
158
}
159
159
160
- let mut table = Table :: new ( ) ;
160
+ let table = Table :: new ( ) ;
161
161
let wasi = WasiCtxBuilder :: new ( )
162
162
. monotonic_clock ( FakeMonotonicClock { now : Mutex :: new ( 0 ) } )
163
163
. wall_clock ( FakeWallClock )
164
- . build ( & mut table ) ? ;
164
+ . build ( ) ;
165
165
166
166
let ( mut store, command) =
167
167
instantiate ( get_component ( "time" ) , CommandCtx { table, wasi } ) . await ?;
@@ -175,13 +175,12 @@ async fn time() -> Result<()> {
175
175
176
176
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
177
177
async fn stdin ( ) -> Result < ( ) > {
178
- let mut table = Table :: new ( ) ;
178
+ let table = Table :: new ( ) ;
179
179
let wasi = WasiCtxBuilder :: new ( )
180
- . stdin (
181
- MemoryInputPipe :: new ( "So rested he by the Tumtum tree" . into ( ) ) ,
182
- IsATTY :: No ,
183
- )
184
- . build ( & mut table) ?;
180
+ . stdin ( MemoryInputPipe :: new (
181
+ "So rested he by the Tumtum tree" . into ( ) ,
182
+ ) )
183
+ . build ( ) ;
185
184
186
185
let ( mut store, command) =
187
186
instantiate ( get_component ( "stdin" ) , CommandCtx { table, wasi } ) . await ?;
@@ -195,13 +194,12 @@ async fn stdin() -> Result<()> {
195
194
196
195
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
197
196
async fn poll_stdin ( ) -> Result < ( ) > {
198
- let mut table = Table :: new ( ) ;
197
+ let table = Table :: new ( ) ;
199
198
let wasi = WasiCtxBuilder :: new ( )
200
- . stdin (
201
- MemoryInputPipe :: new ( "So rested he by the Tumtum tree" . into ( ) ) ,
202
- IsATTY :: No ,
203
- )
204
- . build ( & mut table) ?;
199
+ . stdin ( MemoryInputPipe :: new (
200
+ "So rested he by the Tumtum tree" . into ( ) ,
201
+ ) )
202
+ . build ( ) ;
205
203
206
204
let ( mut store, command) =
207
205
instantiate ( get_component ( "poll_stdin" ) , CommandCtx { table, wasi } ) . await ?;
@@ -215,11 +213,11 @@ async fn poll_stdin() -> Result<()> {
215
213
216
214
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
217
215
async fn env ( ) -> Result < ( ) > {
218
- let mut table = Table :: new ( ) ;
216
+ let table = Table :: new ( ) ;
219
217
let wasi = WasiCtxBuilder :: new ( )
220
218
. env ( "frabjous" , "day" )
221
219
. env ( "callooh" , "callay" )
222
- . build ( & mut table ) ? ;
220
+ . build ( ) ;
223
221
224
222
let ( mut store, command) =
225
223
instantiate ( get_component ( "env" ) , CommandCtx { table, wasi } ) . await ?;
@@ -239,10 +237,10 @@ async fn file_read() -> Result<()> {
239
237
240
238
let open_dir = Dir :: open_ambient_dir ( dir. path ( ) , ambient_authority ( ) ) ?;
241
239
242
- let mut table = Table :: new ( ) ;
240
+ let table = Table :: new ( ) ;
243
241
let wasi = WasiCtxBuilder :: new ( )
244
242
. preopened_dir ( open_dir, DirPerms :: all ( ) , FilePerms :: all ( ) , "/" )
245
- . build ( & mut table ) ? ;
243
+ . build ( ) ;
246
244
247
245
let ( mut store, command) =
248
246
instantiate ( get_component ( "file_read" ) , CommandCtx { table, wasi } ) . await ?;
@@ -263,10 +261,10 @@ async fn file_append() -> Result<()> {
263
261
264
262
let open_dir = Dir :: open_ambient_dir ( dir. path ( ) , ambient_authority ( ) ) ?;
265
263
266
- let mut table = Table :: new ( ) ;
264
+ let table = Table :: new ( ) ;
267
265
let wasi = WasiCtxBuilder :: new ( )
268
266
. preopened_dir ( open_dir, DirPerms :: all ( ) , FilePerms :: all ( ) , "/" )
269
- . build ( & mut table ) ? ;
267
+ . build ( ) ;
270
268
271
269
let ( mut store, command) =
272
270
instantiate ( get_component ( "file_append" ) , CommandCtx { table, wasi } ) . await ?;
@@ -296,10 +294,10 @@ async fn file_dir_sync() -> Result<()> {
296
294
297
295
let open_dir = Dir :: open_ambient_dir ( dir. path ( ) , ambient_authority ( ) ) ?;
298
296
299
- let mut table = Table :: new ( ) ;
297
+ let table = Table :: new ( ) ;
300
298
let wasi = WasiCtxBuilder :: new ( )
301
299
. preopened_dir ( open_dir, DirPerms :: all ( ) , FilePerms :: all ( ) , "/" )
302
- . build ( & mut table ) ? ;
300
+ . build ( ) ;
303
301
304
302
let ( mut store, command) =
305
303
instantiate ( get_component ( "file_dir_sync" ) , CommandCtx { table, wasi } ) . await ?;
@@ -313,8 +311,8 @@ async fn file_dir_sync() -> Result<()> {
313
311
314
312
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
315
313
async fn exit_success ( ) -> Result < ( ) > {
316
- let mut table = Table :: new ( ) ;
317
- let wasi = WasiCtxBuilder :: new ( ) . build ( & mut table ) ? ;
314
+ let table = Table :: new ( ) ;
315
+ let wasi = WasiCtxBuilder :: new ( ) . build ( ) ;
318
316
319
317
let ( mut store, command) =
320
318
instantiate ( get_component ( "exit_success" ) , CommandCtx { table, wasi } ) . await ?;
@@ -330,8 +328,8 @@ async fn exit_success() -> Result<()> {
330
328
331
329
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
332
330
async fn exit_default ( ) -> Result < ( ) > {
333
- let mut table = Table :: new ( ) ;
334
- let wasi = WasiCtxBuilder :: new ( ) . build ( & mut table ) ? ;
331
+ let table = Table :: new ( ) ;
332
+ let wasi = WasiCtxBuilder :: new ( ) . build ( ) ;
335
333
336
334
let ( mut store, command) =
337
335
instantiate ( get_component ( "exit_default" ) , CommandCtx { table, wasi } ) . await ?;
@@ -343,8 +341,8 @@ async fn exit_default() -> Result<()> {
343
341
344
342
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
345
343
async fn exit_failure ( ) -> Result < ( ) > {
346
- let mut table = Table :: new ( ) ;
347
- let wasi = WasiCtxBuilder :: new ( ) . build ( & mut table ) ? ;
344
+ let table = Table :: new ( ) ;
345
+ let wasi = WasiCtxBuilder :: new ( ) . build ( ) ;
348
346
349
347
let ( mut store, command) =
350
348
instantiate ( get_component ( "exit_failure" ) , CommandCtx { table, wasi } ) . await ?;
@@ -360,8 +358,8 @@ async fn exit_failure() -> Result<()> {
360
358
361
359
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
362
360
async fn exit_panic ( ) -> Result < ( ) > {
363
- let mut table = Table :: new ( ) ;
364
- let wasi = WasiCtxBuilder :: new ( ) . build ( & mut table ) ? ;
361
+ let table = Table :: new ( ) ;
362
+ let wasi = WasiCtxBuilder :: new ( ) . build ( ) ;
365
363
366
364
let ( mut store, command) =
367
365
instantiate ( get_component ( "exit_panic" ) , CommandCtx { table, wasi } ) . await ?;
@@ -388,12 +386,12 @@ async fn directory_list() -> Result<()> {
388
386
389
387
let open_dir = Dir :: open_ambient_dir ( dir. path ( ) , ambient_authority ( ) ) ?;
390
388
391
- let mut table = Table :: new ( ) ;
389
+ let table = Table :: new ( ) ;
392
390
let wasi = WasiCtxBuilder :: new ( )
393
391
. inherit_stdout ( )
394
392
. inherit_stderr ( )
395
393
. preopened_dir ( open_dir, DirPerms :: all ( ) , FilePerms :: all ( ) , "/" )
396
- . build ( & mut table ) ? ;
394
+ . build ( ) ;
397
395
398
396
let ( mut store, command) =
399
397
instantiate ( get_component ( "directory_list" ) , CommandCtx { table, wasi } ) . await ?;
@@ -407,8 +405,8 @@ async fn directory_list() -> Result<()> {
407
405
408
406
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
409
407
async fn default_clocks ( ) -> Result < ( ) > {
410
- let mut table = Table :: new ( ) ;
411
- let wasi = WasiCtxBuilder :: new ( ) . build ( & mut table ) ? ;
408
+ let table = Table :: new ( ) ;
409
+ let wasi = WasiCtxBuilder :: new ( ) . build ( ) ;
412
410
413
411
let ( mut store, command) =
414
412
instantiate ( get_component ( "default_clocks" ) , CommandCtx { table, wasi } ) . await ?;
@@ -422,8 +420,8 @@ async fn default_clocks() -> Result<()> {
422
420
423
421
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
424
422
async fn export_cabi_realloc ( ) -> Result < ( ) > {
425
- let mut table = Table :: new ( ) ;
426
- let wasi = WasiCtxBuilder :: new ( ) . build ( & mut table ) ? ;
423
+ let table = Table :: new ( ) ;
424
+ let wasi = WasiCtxBuilder :: new ( ) . build ( ) ;
427
425
let ( mut store, command) = instantiate (
428
426
get_component ( "export_cabi_realloc" ) ,
429
427
CommandCtx { table, wasi } ,
@@ -444,11 +442,11 @@ async fn read_only() -> Result<()> {
444
442
std:: fs:: File :: create ( dir. path ( ) . join ( "bar.txt" ) ) ?. write_all ( b"And stood awhile in thought" ) ?;
445
443
std:: fs:: create_dir ( dir. path ( ) . join ( "sub" ) ) ?;
446
444
447
- let mut table = Table :: new ( ) ;
445
+ let table = Table :: new ( ) ;
448
446
let open_dir = Dir :: open_ambient_dir ( dir. path ( ) , ambient_authority ( ) ) ?;
449
447
let wasi = WasiCtxBuilder :: new ( )
450
448
. preopened_dir ( open_dir, DirPerms :: READ , FilePerms :: READ , "/" )
451
- . build ( & mut table ) ? ;
449
+ . build ( ) ;
452
450
453
451
let ( mut store, command) =
454
452
instantiate ( get_component ( "read_only" ) , CommandCtx { table, wasi } ) . await ?;
@@ -461,16 +459,15 @@ async fn read_only() -> Result<()> {
461
459
}
462
460
463
461
#[ test_log:: test( tokio:: test( flavor = "multi_thread" ) ) ]
464
- #[ ignore] // FIXME: this calls get_stdin but it's already consumed
465
462
async fn stream_pollable_lifetimes ( ) -> Result < ( ) > {
466
463
// Test program has two modes, dispatching based on argument.
467
464
{
468
465
// Correct execution: should succeed
469
- let mut table = Table :: new ( ) ;
466
+ let table = Table :: new ( ) ;
470
467
let wasi = WasiCtxBuilder :: new ( )
471
468
. args ( & [ "correct" ] )
472
- . stdin ( MemoryInputPipe :: new ( " " . into ( ) ) , IsATTY :: No )
473
- . build ( & mut table ) ? ;
469
+ . stdin ( MemoryInputPipe :: new ( " " . into ( ) ) )
470
+ . build ( ) ;
474
471
475
472
let ( mut store, command) = instantiate (
476
473
get_component ( "stream_pollable_lifetimes" ) ,
@@ -486,11 +483,11 @@ async fn stream_pollable_lifetimes() -> Result<()> {
486
483
}
487
484
{
488
485
// Incorrect execution: should trap with a TableError::HasChildren
489
- let mut table = Table :: new ( ) ;
486
+ let table = Table :: new ( ) ;
490
487
let wasi = WasiCtxBuilder :: new ( )
491
488
. args ( & [ "trap" ] )
492
- . stdin ( MemoryInputPipe :: new ( " " . into ( ) ) , IsATTY :: No )
493
- . build ( & mut table ) ? ;
489
+ . stdin ( MemoryInputPipe :: new ( " " . into ( ) ) )
490
+ . build ( ) ;
494
491
495
492
let ( mut store, command) = instantiate (
496
493
get_component ( "stream_pollable_lifetimes" ) ,
0 commit comments