common.fail() was added to paste over issues with assert.fail() function signature. assert.fail() has been updated to accept a single argument so common.fail() is no longer necessary. Backport-PR-URL: https://github.com/nodejs/node/pull/15479 PR-URL: https://github.com/nodejs/node/pull/12293 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
24 lines
651 B
JavaScript
24 lines
651 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const child_process = require('child_process');
|
|
|
|
const p = child_process.spawn(process.execPath, [
|
|
'-e',
|
|
'vm = require("vm");' +
|
|
'context = vm.createContext({});' +
|
|
'try { vm.runInContext("throw new Error(\'boo\')", context); } ' +
|
|
'catch (e) { console.log(e.message); }'
|
|
]);
|
|
|
|
p.stderr.on('data', function(data) {
|
|
assert.fail(`Unexpected stderr data: ${data}`);
|
|
});
|
|
|
|
let output = '';
|
|
|
|
p.stdout.on('data', (data) => output += data);
|
|
|
|
p.stdout.on('end', common.mustCall(() => {
|
|
assert.strictEqual(output.replace(/[\r\n]+/g, ''), 'boo');
|
|
}));
|