mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 22:28:51 +02:00
wasi: make version non-optional
- remove default for version - updates tests to specify version - add test for when version is not specified Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: https://github.com/nodejs/node/pull/47391 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
d56c0f7318
commit
4b52727976
11 changed files with 54 additions and 83 deletions
|
@ -118,6 +118,9 @@ added:
|
||||||
- v13.3.0
|
- v13.3.0
|
||||||
- v12.16.0
|
- v12.16.0
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/47391
|
||||||
|
description: The version option is now required and has no default value.
|
||||||
- version: v19.8.0
|
- version: v19.8.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/46469
|
pr-url: https://github.com/nodejs/node/pull/46469
|
||||||
description: version field added to options.
|
description: version field added to options.
|
||||||
|
@ -144,7 +147,8 @@ changes:
|
||||||
* `stderr` {integer} The file descriptor used as standard error in the
|
* `stderr` {integer} The file descriptor used as standard error in the
|
||||||
WebAssembly application. **Default:** `2`.
|
WebAssembly application. **Default:** `2`.
|
||||||
* `version` {string} The version of WASI requested. Currently the only
|
* `version` {string} The version of WASI requested. Currently the only
|
||||||
supported versions are `unstable` and `preview1`. **Default:** `preview1`.
|
supported versions are `unstable` and `preview1`. This option is
|
||||||
|
mandatory.
|
||||||
|
|
||||||
### `wasi.getImportObject()`
|
### `wasi.getImportObject()`
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,12 @@ class WASI {
|
||||||
validateObject(options, 'options');
|
validateObject(options, 'options');
|
||||||
|
|
||||||
let _WASI;
|
let _WASI;
|
||||||
if (options.version !== undefined) {
|
|
||||||
validateString(options.version, 'options.version');
|
validateString(options.version, 'options.version');
|
||||||
switch (options.version) {
|
switch (options.version) {
|
||||||
case 'unstable':
|
case 'unstable':
|
||||||
({ WASI: _WASI } = internalBinding('wasi'));
|
({ WASI: _WASI } = internalBinding('wasi'));
|
||||||
this[kBindingName] = 'wasi_unstable';
|
this[kBindingName] = 'wasi_unstable';
|
||||||
break;
|
break;
|
||||||
// When adding support for additional wasi versions add case here
|
|
||||||
case 'preview1':
|
case 'preview1':
|
||||||
({ WASI: _WASI } = internalBinding('wasi'));
|
({ WASI: _WASI } = internalBinding('wasi'));
|
||||||
this[kBindingName] = 'wasi_snapshot_preview1';
|
this[kBindingName] = 'wasi_snapshot_preview1';
|
||||||
|
@ -66,11 +64,6 @@ class WASI {
|
||||||
options.version,
|
options.version,
|
||||||
'unsupported WASI version');
|
'unsupported WASI version');
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// TODO(mdawson): Remove this in a SemVer major PR before Node.js 20
|
|
||||||
({ WASI: _WASI } = internalBinding('wasi'));
|
|
||||||
this[kBindingName] = 'wasi_snapshot_preview1';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.args !== undefined)
|
if (options.args !== undefined)
|
||||||
validateArray(options.args, 'options.args');
|
validateArray(options.args, 'options.args');
|
||||||
|
|
|
@ -9,7 +9,7 @@ const modulePath = path.join(wasmDir, 'exitcode.wasm');
|
||||||
const buffer = fs.readFileSync(modulePath);
|
const buffer = fs.readFileSync(modulePath);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const wasi = new WASI({ returnOnExit: true });
|
const wasi = new WASI({ version: 'preview1', returnOnExit: true });
|
||||||
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
||||||
const { instance } = await WebAssembly.instantiate(buffer, importObject);
|
const { instance } = await WebAssembly.instantiate(buffer, importObject);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ const buffer = fs.readFileSync(modulePath);
|
||||||
(async () => {
|
(async () => {
|
||||||
// Verify that if a WASI application throws an exception, Node rethrows it
|
// Verify that if a WASI application throws an exception, Node rethrows it
|
||||||
// properly.
|
// properly.
|
||||||
const wasi = new WASI({ returnOnExit: true });
|
const wasi = new WASI({ version: 'preview1', returnOnExit: true });
|
||||||
const patchedExit = () => { throw new Error('test error'); };
|
const patchedExit = () => { throw new Error('test error'); };
|
||||||
wasi.wasiImport.proc_exit = patchedExit.bind(wasi.wasiImport);
|
wasi.wasiImport.proc_exit = patchedExit.bind(wasi.wasiImport);
|
||||||
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
||||||
|
|
|
@ -11,7 +11,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
(async () => {
|
(async () => {
|
||||||
{
|
{
|
||||||
// Verify that a WebAssembly.Instance is passed in.
|
// Verify that a WebAssembly.Instance is passed in.
|
||||||
const wasi = new WASI();
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => { wasi.initialize(); },
|
() => { wasi.initialize(); },
|
||||||
|
@ -24,7 +24,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that the passed instance has an exports objects.
|
// Verify that the passed instance has an exports objects.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that a _initialize() export was passed.
|
// Verify that a _initialize() export was passed.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that a _start export was not passed.
|
// Verify that a _start export was not passed.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that a memory export was passed.
|
// Verify that a memory export was passed.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that a WebAssembly.Instance from another VM context is accepted.
|
// Verify that a WebAssembly.Instance from another VM context is accepted.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const instance = await vm.runInNewContext(`
|
const instance = await vm.runInNewContext(`
|
||||||
(async () => {
|
(async () => {
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
|
@ -130,7 +130,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that initialize() can only be called once.
|
// Verify that initialize() can only be called once.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ if (process.argv[2] === 'wasi-child') {
|
||||||
|
|
||||||
const { WASI } = require('wasi');
|
const { WASI } = require('wasi');
|
||||||
const wasi = new WASI({
|
const wasi = new WASI({
|
||||||
|
version: 'preview1',
|
||||||
args: ['foo', '-bar', '--baz=value'],
|
args: ['foo', '-bar', '--baz=value'],
|
||||||
});
|
});
|
||||||
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
||||||
|
|
|
@ -5,34 +5,34 @@ const assert = require('assert');
|
||||||
const { WASI } = require('wasi');
|
const { WASI } = require('wasi');
|
||||||
|
|
||||||
// If args is undefined, it should default to [] and should not throw.
|
// If args is undefined, it should default to [] and should not throw.
|
||||||
new WASI({});
|
new WASI({ version: 'preview1' });
|
||||||
|
|
||||||
// If args is not an Array and not undefined, it should throw.
|
// If args is not an Array and not undefined, it should throw.
|
||||||
assert.throws(() => { new WASI({ args: 'fhqwhgads' }); },
|
assert.throws(() => { new WASI({ version: 'preview1', args: 'fhqwhgads' }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bargs\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bargs\b/ });
|
||||||
|
|
||||||
// If env is not an Object and not undefined, it should throw.
|
// If env is not an Object and not undefined, it should throw.
|
||||||
assert.throws(() => { new WASI({ env: 'fhqwhgads' }); },
|
assert.throws(() => { new WASI({ version: 'preview1', env: 'fhqwhgads' }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\benv\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\benv\b/ });
|
||||||
|
|
||||||
// If preopens is not an Object and not undefined, it should throw.
|
// If preopens is not an Object and not undefined, it should throw.
|
||||||
assert.throws(() => { new WASI({ preopens: 'fhqwhgads' }); },
|
assert.throws(() => { new WASI({ version: 'preview1', preopens: 'fhqwhgads' }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bpreopens\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bpreopens\b/ });
|
||||||
|
|
||||||
// If returnOnExit is not a boolean and not undefined, it should throw.
|
// If returnOnExit is not a boolean and not undefined, it should throw.
|
||||||
assert.throws(() => { new WASI({ returnOnExit: 'fhqwhgads' }); },
|
assert.throws(() => { new WASI({ version: 'preview1', returnOnExit: 'fhqwhgads' }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\breturnOnExit\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\breturnOnExit\b/ });
|
||||||
|
|
||||||
// If stdin is not an int32 and not undefined, it should throw.
|
// If stdin is not an int32 and not undefined, it should throw.
|
||||||
assert.throws(() => { new WASI({ stdin: 'fhqwhgads' }); },
|
assert.throws(() => { new WASI({ version: 'preview1', stdin: 'fhqwhgads' }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bstdin\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bstdin\b/ });
|
||||||
|
|
||||||
// If stdout is not an int32 and not undefined, it should throw.
|
// If stdout is not an int32 and not undefined, it should throw.
|
||||||
assert.throws(() => { new WASI({ stdout: 'fhqwhgads' }); },
|
assert.throws(() => { new WASI({ version: 'preview1', stdout: 'fhqwhgads' }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bstdout\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bstdout\b/ });
|
||||||
|
|
||||||
// If stderr is not an int32 and not undefined, it should throw.
|
// If stderr is not an int32 and not undefined, it should throw.
|
||||||
assert.throws(() => { new WASI({ stderr: 'fhqwhgads' }); },
|
assert.throws(() => { new WASI({ version: 'preview1', stderr: 'fhqwhgads' }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bstderr\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bstderr\b/ });
|
||||||
|
|
||||||
// If options is provided, but not an object, the constructor should throw.
|
// If options is provided, but not an object, the constructor should throw.
|
||||||
|
@ -43,13 +43,16 @@ assert.throws(() => { new WASI({ stderr: 'fhqwhgads' }); },
|
||||||
|
|
||||||
// Verify that exceptions thrown from the binding layer are handled.
|
// Verify that exceptions thrown from the binding layer are handled.
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
new WASI({ preopens: { '/sandbox': '__/not/real/path' } });
|
new WASI({ version: 'preview1', preopens: { '/sandbox': '__/not/real/path' } });
|
||||||
}, { code: 'UVWASI_ENOENT', message: /uvwasi_init/ });
|
}, { code: 'UVWASI_ENOENT', message: /uvwasi_init/ });
|
||||||
|
|
||||||
// If version is not a string, it should throw
|
// If version is not a string, it should throw
|
||||||
assert.throws(() => { new WASI({ version: { x: 'y' } }); },
|
assert.throws(() => { new WASI({ version: { x: 'y' } }); },
|
||||||
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bversion\b/ });
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bversion\b/ });
|
||||||
|
|
||||||
|
// If version is not specified, it should throw.
|
||||||
|
assert.throws(() => { new WASI(); },
|
||||||
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bversion\b/ });
|
||||||
|
|
||||||
// If version is an unsupported version, it should throw
|
// If version is an unsupported version, it should throw
|
||||||
assert.throws(() => { new WASI({ version: 'not_a_version' }); },
|
assert.throws(() => { new WASI({ version: 'not_a_version' }); },
|
||||||
|
|
|
@ -11,7 +11,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
(async () => {
|
(async () => {
|
||||||
{
|
{
|
||||||
// Verify that a WebAssembly.Instance is passed in.
|
// Verify that a WebAssembly.Instance is passed in.
|
||||||
const wasi = new WASI();
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => { wasi.start(); },
|
() => { wasi.start(); },
|
||||||
|
@ -24,7 +24,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that the passed instance has an exports objects.
|
// Verify that the passed instance has an exports objects.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that a _start() export was passed.
|
// Verify that a _start() export was passed.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that an _initialize export was not passed.
|
// Verify that an _initialize export was not passed.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that a memory export was passed.
|
// Verify that a memory export was passed.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that a WebAssembly.Instance from another VM context is accepted.
|
// Verify that a WebAssembly.Instance from another VM context is accepted.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const instance = await vm.runInNewContext(`
|
const instance = await vm.runInNewContext(`
|
||||||
(async () => {
|
(async () => {
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
|
@ -127,7 +127,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify that start() can only be called once.
|
// Verify that start() can only be called once.
|
||||||
const wasi = new WASI({});
|
const wasi = new WASI({ version: 'preview1' });
|
||||||
const wasm = await WebAssembly.compile(bufferSource);
|
const wasm = await WebAssembly.compile(bufferSource);
|
||||||
const instance = await WebAssembly.instantiate(wasm);
|
const instance = await WebAssembly.instantiate(wasm);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ writeFileSync(stdinFile, 'x'.repeat(33));
|
||||||
const stdin = openSync(stdinFile, 'r');
|
const stdin = openSync(stdinFile, 'r');
|
||||||
const stdout = openSync(stdoutFile, 'a');
|
const stdout = openSync(stdoutFile, 'a');
|
||||||
const stderr = openSync(stderrFile, 'a');
|
const stderr = openSync(stderrFile, 'a');
|
||||||
const wasi = new WASI({ stdin, stdout, stderr, returnOnExit: true });
|
const wasi = new WASI({ version: 'preview1', stdin, stdout, stderr, returnOnExit: true });
|
||||||
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
|
@ -10,6 +10,7 @@ if (process.argv[2] === 'wasi-child') {
|
||||||
const { WASI } = require('wasi');
|
const { WASI } = require('wasi');
|
||||||
const wasmDir = path.join(__dirname, 'wasm');
|
const wasmDir = path.join(__dirname, 'wasm');
|
||||||
const wasi = new WASI({
|
const wasi = new WASI({
|
||||||
|
version: 'preview1',
|
||||||
args: [],
|
args: [],
|
||||||
env: process.env,
|
env: process.env,
|
||||||
preopens: {
|
preopens: {
|
||||||
|
|
|
@ -34,7 +34,7 @@ if (!process.env.HAS_STARTED_WORKER) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function go() {
|
async function go() {
|
||||||
const wasi = new WASI({ returnOnExit: true });
|
const wasi = new WASI({ version: 'preview1', returnOnExit: true });
|
||||||
const imports = { wasi_snapshot_preview1: wasi.wasiImport };
|
const imports = { wasi_snapshot_preview1: wasi.wasiImport };
|
||||||
const module = await WebAssembly.compile(bytecode);
|
const module = await WebAssembly.compile(bytecode);
|
||||||
const instance = await WebAssembly.instantiate(module, imports);
|
const instance = await WebAssembly.instantiate(module, imports);
|
||||||
|
|
|
@ -1,37 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
if (process.argv[2] === 'wasi-child-default') {
|
if (process.argv[2] === 'wasi-child-preview1') {
|
||||||
// test default case
|
|
||||||
const fixtures = require('../common/fixtures');
|
|
||||||
const tmpdir = require('../common/tmpdir');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
common.expectWarning('ExperimentalWarning',
|
|
||||||
'WASI is an experimental feature and might change at any time');
|
|
||||||
|
|
||||||
const { WASI } = require('wasi');
|
|
||||||
tmpdir.refresh();
|
|
||||||
const wasmDir = path.join(__dirname, 'wasm');
|
|
||||||
const wasi = new WASI({
|
|
||||||
args: ['foo', '-bar', '--baz=value'],
|
|
||||||
env: process.env,
|
|
||||||
preopens: {
|
|
||||||
'/sandbox': fixtures.path('wasi'),
|
|
||||||
'/tmp': tmpdir.path,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
|
||||||
const modulePath = path.join(wasmDir, `${process.argv[3]}.wasm`);
|
|
||||||
const buffer = fs.readFileSync(modulePath);
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const { instance } = await WebAssembly.instantiate(buffer, importObject);
|
|
||||||
|
|
||||||
wasi.start(instance);
|
|
||||||
})().then(common.mustCall());
|
|
||||||
} else if (process.argv[2] === 'wasi-child-preview1') {
|
|
||||||
// Test version set to preview1
|
// Test version set to preview1
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
|
@ -73,7 +43,7 @@ if (process.argv[2] === 'wasi-child-default') {
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
const { checkoutEOL } = common;
|
const { checkoutEOL } = common;
|
||||||
|
|
||||||
function innerRunWASI(options, args, flavor = 'default') {
|
function innerRunWASI(options, args, flavor = 'preview1') {
|
||||||
console.log('executing', options.test);
|
console.log('executing', options.test);
|
||||||
const opts = {
|
const opts = {
|
||||||
env: {
|
env: {
|
||||||
|
@ -101,7 +71,6 @@ if (process.argv[2] === 'wasi-child-default') {
|
||||||
function runWASI(options) {
|
function runWASI(options) {
|
||||||
innerRunWASI(options, ['--no-turbo-fast-api-calls']);
|
innerRunWASI(options, ['--no-turbo-fast-api-calls']);
|
||||||
innerRunWASI(options, ['--turbo-fast-api-calls']);
|
innerRunWASI(options, ['--turbo-fast-api-calls']);
|
||||||
innerRunWASI(options, ['--turbo-fast-api-calls'], 'preview1');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runWASI({ test: 'cant_dotdot' });
|
runWASI({ test: 'cant_dotdot' });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue