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-print-help.js
Joyee Cheung c2359bdad6
process: expose process.features.inspector
Instead of using process.config.variables.v8_enable_inspector
to detect whether inspector is enabled in the build.

PR-URL: https://github.com/nodejs/node/pull/25819
Refs: https://github.com/nodejs/node/issues/25343
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-02 05:41:45 +08:00

60 lines
1.8 KiB
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
// The following tests assert that the node.cc PrintHelp() function
// returns the proper set of cli options when invoked
const assert = require('assert');
const { exec } = require('child_process');
const { internalBinding } = require('internal/test/binding');
const { fipsMode } = internalBinding('config');
let stdOut;
function startPrintHelpTest() {
exec(`${process.execPath} --help`, common.mustCall((err, stdout, stderr) => {
assert.ifError(err);
stdOut = stdout;
validateNodePrintHelp();
}));
}
function validateNodePrintHelp() {
const HAVE_OPENSSL = common.hasCrypto;
const NODE_HAVE_I18N_SUPPORT = common.hasIntl;
const HAVE_INSPECTOR = process.features.inspector;
const cliHelpOptions = [
{ compileConstant: HAVE_OPENSSL,
flags: [ '--openssl-config=...', '--tls-cipher-list=...',
'--use-bundled-ca', '--use-openssl-ca' ] },
{ compileConstant: fipsMode,
flags: [ '--enable-fips', '--force-fips' ] },
{ compileConstant: NODE_HAVE_I18N_SUPPORT,
flags: [ '--icu-data-dir=...', 'NODE_ICU_DATA' ] },
{ compileConstant: HAVE_INSPECTOR,
flags: [ '--inspect-brk[=[host:]port]', '--inspect-port=[host:]port',
'--inspect[=[host:]port]' ] },
];
cliHelpOptions.forEach(testForSubstring);
}
function testForSubstring(options) {
if (options.compileConstant) {
options.flags.forEach((flag) => {
assert.strictEqual(stdOut.indexOf(flag) !== -1, true,
`Missing flag ${flag} in ${stdOut}`);
});
} else {
options.flags.forEach((flag) => {
assert.strictEqual(stdOut.indexOf(flag), -1,
`Unexpected flag ${flag} in ${stdOut}`);
});
}
}
startPrintHelpTest();