mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 18:02:21 +00:00

Enable linting for the test directory. A number of changes was made so all tests conform the current rules used by lib and src directories. The only exception for tests is that unreachable (dead) code is allowed. test-fs-non-number-arguments-throw had to be excluded from the changes because of a weird issue on Windows CI. PR-URL: https://github.com/nodejs/io.js/pull/1721 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
'use strict';
|
|
var cluster = require('cluster');
|
|
var assert = require('assert');
|
|
var util = require('util');
|
|
|
|
if (cluster.isMaster) {
|
|
var worker = cluster.fork();
|
|
|
|
assert.ok(worker.isConnected(),
|
|
'isConnected() should return true as soon as the worker has ' +
|
|
'been created.');
|
|
|
|
worker.on('disconnect', function() {
|
|
assert.ok(!worker.isConnected(),
|
|
'After a disconnect event has been emitted, ' +
|
|
'isConncted should return false');
|
|
});
|
|
|
|
worker.on('message', function(msg) {
|
|
if (msg === 'readyToDisconnect') {
|
|
worker.disconnect();
|
|
}
|
|
});
|
|
|
|
} else {
|
|
assert.ok(cluster.worker.isConnected(),
|
|
'isConnected() should return true from within a worker at all ' +
|
|
'times.');
|
|
|
|
cluster.worker.process.on('disconnect', function() {
|
|
assert.ok(!cluster.worker.isConnected(),
|
|
'isConnected() should return false from within a worker ' +
|
|
'after its underlying process has been disconnected from ' +
|
|
'the master');
|
|
});
|
|
|
|
process.send('readyToDisconnect');
|
|
}
|