From 7260dd54e43de172e691a97dee9ea0d7c49e4686 Mon Sep 17 00:00:00 2001 From: dave-k Date: Tue, 18 Apr 2017 19:09:27 -0700 Subject: [PATCH 1/4] test: add inspect-brk option to cluster module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that cluster interoperates with the --inspect-brk option. This does not test for —debug-brk. Fixes: https://github.com/nodejs/node/issues/11420 --- test/parallel/test-cluster-inspect-brk.js | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/parallel/test-cluster-inspect-brk.js diff --git a/test/parallel/test-cluster-inspect-brk.js b/test/parallel/test-cluster-inspect-brk.js new file mode 100644 index 00000000000000..b2864bf81b080a --- /dev/null +++ b/test/parallel/test-cluster-inspect-brk.js @@ -0,0 +1,33 @@ +'use strict'; +const common = require('../common'); + +// A test to ensure that cluster properly interoperates with the +// --inspect-brk option. + +const assert = require('assert'); +const cluster = require('cluster'); +const debuggerPort = common.PORT; + +if (cluster.isMaster) { + function test(execArgv) { + + cluster.setupMaster({ + execArgv: execArgv, + stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'pipe'] + }); + + const worker = cluster.fork(); + + // Debugger listening on port [port]. + worker.process.stderr.once('data', common.mustCall(function() { + worker.process.kill('SIGTERM'); + })); + + worker.process.on('exit', common.mustCall(function(code, signal) { + assert.strictEqual(signal, 'SIGTERM'); + })); + } + + test(['--inspect-brk']); + test([`--inspect-brk=${debuggerPort}`]); +} From 61d06c5325e57c38febc95acbec9822998c831de Mon Sep 17 00:00:00 2001 From: dave-k Date: Wed, 19 Apr 2017 12:35:06 -0700 Subject: [PATCH 2/4] test: assert fail if breakpoint not reached Have the cluster worker print something or crash. Then, test that it doesn't happen because the worker is at a breakpoint. --- test/parallel/test-cluster-inspect-brk.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parallel/test-cluster-inspect-brk.js b/test/parallel/test-cluster-inspect-brk.js index b2864bf81b080a..62cb49fdc8bba4 100644 --- a/test/parallel/test-cluster-inspect-brk.js +++ b/test/parallel/test-cluster-inspect-brk.js @@ -30,4 +30,7 @@ if (cluster.isMaster) { test(['--inspect-brk']); test([`--inspect-brk=${debuggerPort}`]); +} else { + // Cluster worker is at a breakpoint, should not reach here. + assert.fail(1, 2, 'Test failed: cluster worker is at a breakpoint.', '>'); } From 3fbac506015d3243d8e9be1352f8665a0ca11063 Mon Sep 17 00:00:00 2001 From: dave-k Date: Wed, 19 Apr 2017 12:55:33 -0700 Subject: [PATCH 3/4] test: assert fail - use one argument --- test/parallel/test-cluster-inspect-brk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-cluster-inspect-brk.js b/test/parallel/test-cluster-inspect-brk.js index 62cb49fdc8bba4..0fb0b9eaab5b68 100644 --- a/test/parallel/test-cluster-inspect-brk.js +++ b/test/parallel/test-cluster-inspect-brk.js @@ -32,5 +32,5 @@ if (cluster.isMaster) { test([`--inspect-brk=${debuggerPort}`]); } else { // Cluster worker is at a breakpoint, should not reach here. - assert.fail(1, 2, 'Test failed: cluster worker is at a breakpoint.', '>'); + assert.fail('Test failed: cluster worker should be at a breakpoint.'); } From c8f4d11267a5721fafebb337b0f8900d4071ebf3 Mon Sep 17 00:00:00 2001 From: dave-k Date: Tue, 25 Apr 2017 08:28:45 -0700 Subject: [PATCH 4/4] test: move test from parallel to sequential because this test uses common.PORT, moved from parallel to sequential. --- test/{parallel => sequential}/test-cluster-inspect-brk.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{parallel => sequential}/test-cluster-inspect-brk.js (100%) diff --git a/test/parallel/test-cluster-inspect-brk.js b/test/sequential/test-cluster-inspect-brk.js similarity index 100% rename from test/parallel/test-cluster-inspect-brk.js rename to test/sequential/test-cluster-inspect-brk.js