0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-cli-node-options-disallowed.js
Juan José Arboleda 0826935814 test: check that --expose-internals is disallowed in NODE_OPTIONS
Add test cases that confirm that `--expose-internals` and
`--expose_internals` are disallowed in the NODE_OPTIONS environment
variable.

PR-URL: https://github.com/nodejs/node/pull/32554
Refs: https://github.com/nodejs/node/pull/32542
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-05 17:49:36 -07:00

42 lines
1.0 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;
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
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('--expose_internals');
disallow('--expose-internals');
disallow('--');
function disallow(opt) {
const env = { ...process.env, NODE_OPTIONS: opt };
exec(process.execPath, { cwd: tmpdir.path, env }, common.mustCall((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);
}));
}