Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
fixup: revert changes
  • Loading branch information
BridgeAR committed May 21, 2018
commit 3882ba83ec335412987cfb26b45d4a94c4d12107
26 changes: 9 additions & 17 deletions test/parallel/test-buffer-constructor-node-modules-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@ if (process.env.NODE_PENDING_DEPRECATION)
common.skip('test does not work when NODE_PENDING_DEPRECATION is set');

function test(main, callSite, expected) {
const child = child_process.spawn(process.execPath, [
'-p',
`process.mainModule = { filename: ${JSON.stringify(main)} };` +
"vm.runInNewContext('new Buffer(10)', { Buffer }, {" +
` filename: ${JSON.stringify(callSite)}` +
'});'
], { encoding: 'utf8' });
const { stderr } = child_process.spawnSync(process.execPath, ['-p', `
process.mainModule = { filename: ${JSON.stringify(main)} };

let stderr = '';
child.stderr.on('data', (value) => {
stderr += value.toString();
});
child.on('exit', () => {
if (expected)
assert(stderr.includes('[DEP0005] DeprecationWarning'));
else
assert.strictEqual(stderr.trim(), '');
});
vm.runInNewContext('new Buffer(10)', { Buffer }, {
filename: ${JSON.stringify(callSite)}
});`], { encoding: 'utf8' });
if (expected)
assert(stderr.includes('[DEP0005] DeprecationWarning'), stderr);
else
assert.strictEqual(stderr.trim(), '');
}

test('/a/node_modules/b.js', '/a/node_modules/x.js', false);
Expand Down