|
| 1 | +'use strict'; |
| 2 | +// Flags: --inspect={PORT} |
| 3 | +const common = require('../common'); |
| 4 | +const assert = require('assert'); |
| 5 | +const cluster = require('cluster'); |
| 6 | +const debuggerPort = common.PORT; |
| 7 | + |
| 8 | +if (cluster.isMaster) { |
| 9 | + function checkExitCode(code, signal) { |
| 10 | + assert.strictEqual(code, 0); |
| 11 | + assert.strictEqual(signal, null); |
| 12 | + } |
| 13 | + |
| 14 | + function fork(offset, execArgv) { |
| 15 | + if (execArgv) |
| 16 | + cluster.setupMaster({execArgv}); |
| 17 | + |
| 18 | + const check = common.mustCall(checkExitCode); |
| 19 | + cluster.fork({portSet: debuggerPort + offset}).on('exit', check); |
| 20 | + } |
| 21 | + |
| 22 | + assert.strictEqual(process.debugPort, debuggerPort); |
| 23 | + |
| 24 | + fork(1); |
| 25 | + fork(2, ['--inspect']); |
| 26 | + fork(3, [`--inspect=${debuggerPort}`]); |
| 27 | + fork(4, ['--inspect', '--debug']); |
| 28 | + fork(5, [`--debug=${debuggerPort}`, '--inspect']); |
| 29 | + fork(6, ['--inspect', `--debug-port=${debuggerPort}`]); |
| 30 | +} else { |
| 31 | + const hasDebugArg = process.execArgv.some(function(arg) { |
| 32 | + return /inspect/.test(arg); |
| 33 | + }); |
| 34 | + |
| 35 | + assert.strictEqual(hasDebugArg, true); |
| 36 | + assert.strictEqual(process.debugPort, +process.env.portSet); |
| 37 | + process.exit(); |
| 38 | +} |
0 commit comments