forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-cluster-debug-port.js
38 lines (31 loc) · 1.07 KB
/
test-cluster-debug-port.js
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');
const assert = require('assert');
const cluster = require('cluster');
if (cluster.isMaster) {
assert.strictEqual(process.execArgv.length, 0, 'run test with no args');
function checkExitCode(code, signal) {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
}
console.log('forked worker should not have --debug-port');
cluster.fork().on('exit', checkExitCode);
cluster.setupMaster({
execArgv: ['--debug-port=' + process.debugPort]
});
console.log('forked worker should have --debug-port, with offset = 1');
cluster.fork({
portSet: process.debugPort + 1
}).on('exit', checkExitCode);
console.log('forked worker should have --debug-port, with offset = 2');
cluster.fork({
portSet: process.debugPort + 2
}).on('exit', checkExitCode);
} else {
const hasDebugArg = process.execArgv.some(function(arg) {
return /debug/.test(arg);
});
assert.strictEqual(hasDebugArg, process.env.portSet !== undefined);
assert.strictEqual(process.debugPort, +process.env.portSet || 5858);
process.exit();
}