test: add inspect-brk option to cluster module · nodejs/node@7b9710d

1+

'use strict';

2+

const common = require('../common');

3+4+

// A test to ensure that cluster properly interoperates with the

5+

// --inspect-brk option.

6+7+

const assert = require('assert');

8+

const cluster = require('cluster');

9+

const debuggerPort = common.PORT;

10+11+

if (cluster.isMaster) {

12+

function test(execArgv) {

13+14+

cluster.setupMaster({

15+

execArgv: execArgv,

16+

stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'pipe']

17+

});

18+19+

const worker = cluster.fork();

20+21+

// Debugger listening on port [port].

22+

worker.process.stderr.once('data', common.mustCall(function() {

23+

worker.process.kill('SIGTERM');

24+

}));

25+26+

worker.process.on('exit', common.mustCall(function(code, signal) {

27+

assert.strictEqual(signal, 'SIGTERM');

28+

}));

29+

}

30+31+

test(['--inspect-brk']);

32+

test([`--inspect-brk=${debuggerPort}`]);

33+

} else {

34+

// Cluster worker is at a breakpoint, should not reach here.

35+

assert.fail('Test failed: cluster worker should be at a breakpoint.');

36+

}