2017-02-20 15:18:43 +01:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (process.config.variables.node_without_node_options)
|
2017-07-01 01:29:09 +02:00
|
|
|
common.skip('missing NODE_OPTIONS support');
|
2017-02-20 15:18:43 +01:00
|
|
|
|
|
|
|
// Test options specified by env variable.
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const exec = require('child_process').execFile;
|
|
|
|
|
2017-04-26 08:40:15 +02:00
|
|
|
common.refreshTmpDir();
|
|
|
|
process.chdir(common.tmpDir);
|
|
|
|
|
2017-07-12 18:27:28 +02:00
|
|
|
expect(`-r ${require.resolve('../fixtures/printA.js')}`, 'A\nB\n');
|
2017-02-20 15:18:43 +01:00
|
|
|
expect('--no-deprecation', 'B\n');
|
|
|
|
expect('--no-warnings', 'B\n');
|
|
|
|
expect('--trace-warnings', 'B\n');
|
|
|
|
expect('--redirect-warnings=_', 'B\n');
|
|
|
|
expect('--trace-deprecation', 'B\n');
|
|
|
|
expect('--trace-sync-io', 'B\n');
|
|
|
|
expect('--trace-events-enabled', 'B\n');
|
|
|
|
expect('--track-heap-objects', 'B\n');
|
|
|
|
expect('--throw-deprecation', 'B\n');
|
|
|
|
expect('--zero-fill-buffers', 'B\n');
|
|
|
|
expect('--v8-pool-size=10', 'B\n');
|
2017-07-12 18:27:28 +02:00
|
|
|
|
2017-04-27 10:11:40 +02:00
|
|
|
if (common.hasCrypto) {
|
|
|
|
expect('--use-openssl-ca', 'B\n');
|
|
|
|
expect('--use-bundled-ca', 'B\n');
|
|
|
|
expect('--openssl-config=_ossl_cfg', 'B\n');
|
|
|
|
}
|
2017-02-20 15:18:43 +01:00
|
|
|
|
2017-07-05 23:25:55 +02:00
|
|
|
// V8 options
|
|
|
|
expect('--abort_on-uncaught_exception', 'B\n');
|
|
|
|
expect('--max-old-space-size=0', 'B\n');
|
2017-02-20 15:18:43 +01:00
|
|
|
|
|
|
|
function expect(opt, want) {
|
2017-07-12 18:27:28 +02:00
|
|
|
const argv = ['-e', 'console.log("B")'];
|
2017-02-20 15:18:43 +01:00
|
|
|
const opts = {
|
2017-08-15 20:14:54 +02:00
|
|
|
env: Object.assign({}, process.env, { NODE_OPTIONS: opt }),
|
2017-07-12 18:27:28 +02:00
|
|
|
maxBuffer: 1e6,
|
2017-02-20 15:18:43 +01:00
|
|
|
};
|
2017-07-12 18:27:28 +02:00
|
|
|
exec(process.execPath, argv, opts, common.mustCall((err, stdout) => {
|
2017-02-20 15:18:43 +01:00
|
|
|
assert.ifError(err);
|
2017-07-12 18:27:28 +02:00
|
|
|
if (stdout.includes(want)) return;
|
|
|
|
|
|
|
|
const o = JSON.stringify(opt);
|
|
|
|
assert.fail(`For ${o}, failed to find ${want} in: <\n${stdout}\n>`);
|
2017-02-20 15:18:43 +01:00
|
|
|
}));
|
|
|
|
}
|