File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import argparse
2+ import os
3+ import sys
4+
5+ import pywasm # pip install pywasm
6+
7+ parser = argparse .ArgumentParser ()
8+ parser .add_argument ("--version" , action = "store_true" )
9+ parser .add_argument ("--test-file" , action = "store" )
10+ parser .add_argument ("--arg" , action = "append" , default = [])
11+ parser .add_argument ("--env" , action = "append" , default = [])
12+ parser .add_argument ("--dir" , action = "append" , default = [])
13+
14+ args = parser .parse_args ()
15+
16+ if args .version :
17+ print ('pywasm: https://github.com/mohanson/pywasm/releases/latest' )
18+ sys .exit (0 )
19+
20+ runtime = pywasm .core .Runtime ()
21+ wasi = pywasm .wasi .Preview1 (
22+ [os .path .basename (args .test_file )] + args .arg ,
23+ {e : e for e in args .dir },
24+ dict ([e .split ('=' ) for e in args .env ]),
25+ )
26+ wasi .bind (runtime )
27+ exit = wasi .main (runtime , runtime .instance_from_file (args .test_file ))
28+ sys .exit (exit )
You can’t perform that action at this time.
0 commit comments