diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-08-27 17:21:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 11:21:57 +0200 |
commit | 992248e7318dd7c934703ec20f954504ac58b5d6 (patch) | |
tree | 796079f69a5afa3605c3b28bcdb5b581940903a5 /std/wasi/snapshot_preview1_test_runner.ts | |
parent | 59428e3d8a986f99204d33fafcdcf201d3fc55c3 (diff) |
test(std/wasi): seperate test runner into a module (#7191)
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(); |