Skip to content

Commit 0ae4040

Browse files
committed
test: Test WASI without a subprocess.
1 parent 3d4f593 commit 0ae4040

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

tests/test_wasi.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,14 @@ def test_wasi_env_memory():
4343
instance = Instance(Module(store, TEST_BYTES), import_object)
4444

4545
def test_wasi():
46-
python = sys.executable
47-
result = subprocess.check_output(
48-
[
49-
python,
50-
'-c',
51-
'from wasmer import wasi, Store, Module, Instance; \
52-
store = Store(); \
53-
module = Module(store, open("tests/wasi.wasm", "rb").read()); \
54-
wasi_version = wasi.get_version(module, strict=True); \
55-
wasi_env = wasi.StateBuilder("test-program").argument("--foo").environments({"ABC": "DEF", "X": "YZ"}).map_directory("the_host_current_dir", ".").finalize(); \
56-
import_object = wasi_env.generate_import_object(store, wasi_version); \
57-
instance = Instance(module, import_object); \
58-
instance.exports._start()'
59-
]
60-
)
46+
store = Store()
47+
wasi_env = \
48+
wasi.StateBuilder("test-program"). \
49+
argument("--foo"). \
50+
environments({"ABC": "DEF", "X": "YZ"}). \
51+
map_directory("the_host_current_dir", "."). \
52+
finalize()
53+
import_object = wasi_env.generate_import_object(store, wasi.Version.LATEST)
6154

62-
assert result == b'Found program name: `test-program`\n\
63-
Found 1 arguments: --foo\n\
64-
Found 2 environment variables: ABC=DEF, X=YZ\n\
65-
Found 1 preopened directories: DirEntry("/the_host_current_dir")\n'
55+
instance = Instance(Module(store, TEST_BYTES), import_object)
56+
instance.exports._start()

0 commit comments

Comments
 (0)