Skip to content

Commit 0324ac6

Browse files
dave-kaddaleax
authored andcommitted
test: add inspect-brk option to cluster module
Ensure that cluster interoperates with the --inspect-brk option. This does not test for --debug-brk. Fixes: #11420 PR-URL: #12503 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent a3132b0 commit 0324ac6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}

0 commit comments

Comments
 (0)