summaryrefslogtreecommitdiff
path: root/test/parallel/test-cli-bad-options.js
blob: 3fc8980c142509e23866836cbade7edf5002e444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'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`
  );
}