11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciif (process.config.variables.node_without_node_options)
41cb0ef41Sopenharmony_ci  common.skip('missing NODE_OPTIONS support');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// Test options specified by env variable.
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst assert = require('assert');
91cb0ef41Sopenharmony_ciconst exec = require('child_process').execFile;
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
121cb0ef41Sopenharmony_citmpdir.refresh();
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cidisallow('--version');
151cb0ef41Sopenharmony_cidisallow('-v');
161cb0ef41Sopenharmony_cidisallow('--help');
171cb0ef41Sopenharmony_cidisallow('-h');
181cb0ef41Sopenharmony_cidisallow('--eval');
191cb0ef41Sopenharmony_cidisallow('-e');
201cb0ef41Sopenharmony_cidisallow('--print');
211cb0ef41Sopenharmony_cidisallow('-p');
221cb0ef41Sopenharmony_cidisallow('-pe');
231cb0ef41Sopenharmony_cidisallow('--check');
241cb0ef41Sopenharmony_cidisallow('-c');
251cb0ef41Sopenharmony_cidisallow('--interactive');
261cb0ef41Sopenharmony_cidisallow('-i');
271cb0ef41Sopenharmony_cidisallow('--v8-options');
281cb0ef41Sopenharmony_cidisallow('--expose_internals');
291cb0ef41Sopenharmony_cidisallow('--expose-internals');
301cb0ef41Sopenharmony_cidisallow('--');
311cb0ef41Sopenharmony_cidisallow('--test');
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cifunction disallow(opt) {
341cb0ef41Sopenharmony_ci  const env = { ...process.env, NODE_OPTIONS: opt };
351cb0ef41Sopenharmony_ci  exec(process.execPath, { cwd: tmpdir.path, env }, common.mustCall((err) => {
361cb0ef41Sopenharmony_ci    const message = err.message.split(/\r?\n/)[1];
371cb0ef41Sopenharmony_ci    const expect = `${process.execPath}: ${opt} is not allowed in NODE_OPTIONS`;
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci    assert.strictEqual(err.code, 9);
401cb0ef41Sopenharmony_ci    assert.strictEqual(message, expect);
411cb0ef41Sopenharmony_ci  }));
421cb0ef41Sopenharmony_ci}
43