Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve wasi test coverage and simplify tmpdir imports #30770

Merged
merged 2 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/wasi/test-wasi-options-validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

// Flags: --experimental-wasi-unstable-preview0

require('../common');
const assert = require('assert');
const { WASI } = require('wasi');

// If args is undefined, it should default to [] and should not throw.
new WASI({});

// If args is not an Array and not undefined, it should throw.
assert.throws(() => { new WASI({ args: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE' });

// If env is not an Object and not undefined, it should throw.
assert.throws(() => { new WASI({ env: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE' });

// If preopens is not an Object and not undefined, it should throw.
assert.throws(() => { new WASI({ preopens: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it might make sense to verify that the name of the faulty option is correctly mentioned in the message. E.g.,

assert.throws(
  () => { new WASI({ preopens: 'fhqwhgads' }); },
  { code: 'ERR_INVALID_ARG_TYPE', message: /preopens/ }
);

2 changes: 1 addition & 1 deletion test/wasi/test-wasi-symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (process.argv[2] === 'wasi-child') {

const assert = require('assert');
const cp = require('child_process');
const tmpdir = require('../../test/common/tmpdir');
const tmpdir = require('../common/tmpdir');

// Setup the sandbox environment.
tmpdir.refresh();
Expand Down
2 changes: 1 addition & 1 deletion test/wasi/test-wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const common = require('../common');

if (process.argv[2] === 'wasi-child') {
const fixtures = require('../common/fixtures');
const tmpdir = require('../../test/common/tmpdir');
const tmpdir = require('../common/tmpdir');
const fs = require('fs');
const path = require('path');

Expand Down