node/test/parallel/test-cli-node-options-disallowed.js
Refael Ackermann 86e7c61a07
test: split test-cli-node-options
* partitioning the subprocess groups
* use `-e` instead of module
* reduce maxBuffer

PR-URL: https://github.com/nodejs/node/pull/14195
Fixes: https://github.com/nodejs/node/issues/14191
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-09-04 17:52:32 -04:00

41 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../common');
if (process.config.variables.node_without_node_options)
common.skip('missing NODE_OPTIONS support');
// Test options specified by env variable.
const assert = require('assert');
const exec = require('child_process').execFile;
common.refreshTmpDir();
process.chdir(common.tmpDir);
disallow('--version');
disallow('-v');
disallow('--help');
disallow('-h');
disallow('--eval');
disallow('-e');
disallow('--print');
disallow('-p');
disallow('-pe');
disallow('--check');
disallow('-c');
disallow('--interactive');
disallow('-i');
disallow('--v8-options');
disallow('--');
disallow('--no_warnings'); // Node options don't allow '_' instead of '-'.
function disallow(opt) {
const env = Object.assign({}, process.env, { NODE_OPTIONS: opt });
exec(process.execPath, { env }, common.mustCall(function(err) {
const message = err.message.split(/\r?\n/)[1];
const expect = `${process.execPath}: ${opt} is not allowed in NODE_OPTIONS`;
assert.strictEqual(err.code, 9);
assert.strictEqual(message, expect);
}));
}