node/test/parallel/test-cluster-debug-port.js
Stefan Budeanu 23a584d517 test: allow passing args to executable
Add --node-args option that will pass arguments.

PR-URL: https://github.com/nodejs/node/pull/5376
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2016-02-25 14:28:39 -05:00

38 lines
1022 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const cluster = require('cluster');
if (cluster.isMaster) {
function checkExitCode(code, signal) {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
}
console.log('forked worker should not have --debug-port');
cluster.fork().on('exit', checkExitCode);
cluster.setupMaster({
execArgv: ['--debug-port=' + process.debugPort]
});
console.log('forked worker should have --debug-port, with offset = 1');
cluster.fork({
portSet: process.debugPort + 1
}).on('exit', checkExitCode);
console.log('forked worker should have --debug-port, with offset = 2');
cluster.fork({
portSet: process.debugPort + 2
}).on('exit', checkExitCode);
} else {
const hasDebugArg = process.execArgv.some(function(arg) {
return /debug/.test(arg);
});
assert.strictEqual(hasDebugArg, process.env.portSet !== undefined);
assert.strictEqual(process.debugPort, +process.env.portSet || 5858);
process.exit();
}