diff options
Diffstat (limited to 'std/wasi/snapshot_preview1_test_runner.ts')
-rw-r--r-- | std/wasi/snapshot_preview1_test_runner.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/std/wasi/snapshot_preview1_test_runner.ts b/std/wasi/snapshot_preview1_test_runner.ts new file mode 100644 index 000000000..fb29f082e --- /dev/null +++ b/std/wasi/snapshot_preview1_test_runner.ts @@ -0,0 +1,20 @@ +import Context from "./snapshot_preview1.ts"; + +const options = JSON.parse(Deno.args[0]); +const pathname = Deno.args[1]; +const binary = await Deno.readFile(pathname); +const module = await WebAssembly.compile(binary); + +const context = new Context({ + env: options.env, + args: [pathname].concat(options.args), + preopens: options.preopens, +}); + +const instance = new WebAssembly.Instance(module, { + wasi_snapshot_preview1: context.exports, +}); + +context.memory = instance.exports.memory; + +instance.exports._start(); |