blob: 8a77e94babb4facb33249cc262fdbaaf79113229 (
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
28
29
30
31
32
33
34
35
36
37
38
|
'use strict';
require('../common');
// Tests that node exits consistently on bad option syntax.
const assert = require('assert');
const { spawnSync } = require('child_process');
if (process.features.inspector) {
requiresArgument('--inspect-port');
requiresArgument('--inspect-port=');
requiresArgument('--debug-port');
requiresArgument('--debug-port=');
}
requiresArgument('--eval');
missingOption('--allow-fs-read=*', '--experimental-permission');
missingOption('--allow-fs-write=*', '--experimental-permission');
function missingOption(option, requiredOption) {
const r = spawnSync(process.execPath, [option], { encoding: 'utf8' });
assert.strictEqual(r.status, 1);
const message = `${requiredOption} is required`;
assert.match(r.stderr, new RegExp(message));
}
function requiresArgument(option) {
const r = spawnSync(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`
);
}
|