node/test/parallel/test-cli-bad-options.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

28 lines
678 B
JavaScript

'use strict';
require('../common');
// Tests that node exits consistently on bad option syntax.
const assert = require('assert');
const spawn = require('child_process').spawnSync;
if (process.features.inspector) {
requiresArgument('--inspect-port');
requiresArgument('--inspect-port=');
requiresArgument('--debug-port');
requiresArgument('--debug-port=');
}
requiresArgument('--eval');
function requiresArgument(option) {
const r = spawn(process.execPath, [option], { encoding: 'utf8' });
assert.strictEqual(r.status, 9);
const msg = r.stderr.split(/\r?\n/)[0];
assert.strictEqual(
msg,
`${process.execPath}: ${option} requires an argument`
);
}