mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 11:29:26 +00:00

common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. PR-URL: https://github.com/nodejs/node/pull/4408 Reviewed-By: James M Snell <jasnell@gmail.com>
40 lines
909 B
JavaScript
40 lines
909 B
JavaScript
'use strict';
|
|
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');
|
|
});
|
|
});
|