You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
922 B

'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
assert(cluster.isMaster);
var assertsRun = 0;
function emitAndCatch(next) {
cluster.once('setup', function(settings) {
assert.strictEqual(settings.exec, 'new-exec');
console.log('ok "setup" emitted with options set');
assertsRun += 1;
setImmediate(next);
});
cluster.setupMaster({ exec: 'new-exec' });
}
function emitAndCatch2(next) {
cluster.once('setup', function(settings) {
assert('exec' in settings);
console.log('ok "setup" emitted without options set');
assertsRun += 1;
setImmediate(next);
});
cluster.setupMaster();
}
process.on('exit', function() {
assert.strictEqual(assertsRun, 2);
console.log('ok correct number of assertions');
});
emitAndCatch(function() {
emitAndCatch2(function() {
console.log('ok emitted and caught');
});
});