summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-inspector-debug-port.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-10-06 13:09:17 -0400
committercjihrig <cjihrig@gmail.com>2016-10-10 11:37:24 -0400
commit2aa2f85e467120959778e8fab9b69b72959f1856 (patch)
treed540fbf5ac382bcad525c6f657256f168671ab72 /test/parallel/test-cluster-inspector-debug-port.js
parent13a204e5c3c246eb53f3c8398695d1ed0a3c7ca6 (diff)
downloadnode-new-2aa2f85e467120959778e8fab9b69b72959f1856.tar.gz
test: add cluster inspector debug port test
This commit adds a test for the debug port value in cluster workers using the inspector debugger. Refs: https://github.com/nodejs/node/issues/8201 Refs: https://github.com/nodejs/node/pull/8386 Refs: https://github.com/nodejs/node/pull/8550 PR-URL: https://github.com/nodejs/node/pull/8958 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Diffstat (limited to 'test/parallel/test-cluster-inspector-debug-port.js')
-rw-r--r--test/parallel/test-cluster-inspector-debug-port.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/parallel/test-cluster-inspector-debug-port.js b/test/parallel/test-cluster-inspector-debug-port.js
new file mode 100644
index 0000000000..0adb6d2a2b
--- /dev/null
+++ b/test/parallel/test-cluster-inspector-debug-port.js
@@ -0,0 +1,38 @@
+'use strict';
+// Flags: --inspect={PORT}
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
+const debuggerPort = common.PORT;
+
+if (cluster.isMaster) {
+ function checkExitCode(code, signal) {
+ assert.strictEqual(code, 0);
+ assert.strictEqual(signal, null);
+ }
+
+ function fork(offset, execArgv) {
+ if (execArgv)
+ cluster.setupMaster({execArgv});
+
+ const check = common.mustCall(checkExitCode);
+ cluster.fork({portSet: debuggerPort + offset}).on('exit', check);
+ }
+
+ assert.strictEqual(process.debugPort, debuggerPort);
+
+ fork(1);
+ fork(2, ['--inspect']);
+ fork(3, [`--inspect=${debuggerPort}`]);
+ fork(4, ['--inspect', '--debug']);
+ fork(5, [`--debug=${debuggerPort}`, '--inspect']);
+ fork(6, ['--inspect', `--debug-port=${debuggerPort}`]);
+} else {
+ const hasDebugArg = process.execArgv.some(function(arg) {
+ return /inspect/.test(arg);
+ });
+
+ assert.strictEqual(hasDebugArg, true);
+ assert.strictEqual(process.debugPort, +process.env.portSet);
+ process.exit();
+}