Skip to content

Commit

Permalink
split wasi test in two
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Mar 1, 2021
1 parent e6cbec5 commit 55e5b94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ const wasmDir = path.join(__dirname, 'wasm');
const modulePath = path.join(wasmDir, 'exitcode.wasm');
const buffer = fs.readFileSync(modulePath);

(async () => {
const wasi = new WASI({ returnOnExit: true });
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
const { instance } = await WebAssembly.instantiate(buffer, importObject);

assert.strictEqual(wasi.start(instance), 120);
})().then(common.mustCall());

(async () => {
// Verify that if a WASI application throws an exception, Node rethrows it
// properly.
Expand Down
18 changes: 18 additions & 0 deletions test/wasi/test-return-on-exit-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Flags: --experimental-wasi-unstable-preview1
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { WASI } = require('wasi');
const wasmDir = path.join(__dirname, 'wasm');
const modulePath = path.join(wasmDir, 'exitcode.wasm');
const buffer = fs.readFileSync(modulePath);

(async () => {
const wasi = new WASI({ returnOnExit: true });
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
const { instance } = await WebAssembly.instantiate(buffer, importObject);

assert.strictEqual(wasi.start(instance), 120);
})().then(common.mustCall());

0 comments on commit 55e5b94

Please sign in to comment.