aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/fixtures/clustered-server/app.js11
-rw-r--r--test/simple/test-debug-cluster.js14
-rw-r--r--test/simple/test-debug-port-cluster.js13
3 files changed, 11 insertions, 27 deletions
diff --git a/test/fixtures/clustered-server/app.js b/test/fixtures/clustered-server/app.js
index 16ebc69741..86d66c5e88 100644
--- a/test/fixtures/clustered-server/app.js
+++ b/test/fixtures/clustered-server/app.js
@@ -11,10 +11,13 @@ var workersOnline = 0;
if (cluster.isMaster) {
cluster.on('online', function() {
- workersOnline++;
- if (workersOnline == NUMBER_OF_WORKERS)
- console.error('all workers are running');
- });
+ if (++workersOnline === NUMBER_OF_WORKERS) {
+ console.error('all workers are running');
+ for (var key in cluster.workers) {
+ cluster.workers[key].disconnect();
+ }
+ }
+ });
for (var i = 0; i < NUMBER_OF_WORKERS; i++) {
cluster.fork();
diff --git a/test/simple/test-debug-cluster.js b/test/simple/test-debug-cluster.js
index d91f9cafc8..236418102c 100644
--- a/test/simple/test-debug-cluster.js
+++ b/test/simple/test-debug-cluster.js
@@ -27,7 +27,6 @@ var args = ['--debug', common.fixturesDir + '/clustered-server/app.js' ];
var child = spawn(process.execPath, args);
var outputLines = [];
-
child.stderr.on('data', function(data) {
var lines = data.toString().replace(/\r/g, '').trim().split('\n');
var line = lines[0];
@@ -36,21 +35,12 @@ child.stderr.on('data', function(data) {
if (line === 'all workers are running') {
assertOutputLines();
- process.exit();
} else {
outputLines = outputLines.concat(lines);
}
});
-setTimeout(function testTimedOut() {
- assert(false, 'test timed out.');
-}, 3000);
-
-process.on('exit', function() {
- child.kill();
-});
-
-function assertOutputLines() {
+var assertOutputLines = common.mustCall(function() {
var expectedLines = [
'debugger listening on port ' + 5858,
'debugger listening on port ' + 5859,
@@ -65,4 +55,4 @@ function assertOutputLines() {
assert.equal(outputLines.length, expectedLines.length)
for (var i = 0; i < expectedLines.length; i++)
assert.equal(outputLines[i], expectedLines[i]);
-}
+});
diff --git a/test/simple/test-debug-port-cluster.js b/test/simple/test-debug-port-cluster.js
index 8a74ba1e72..729eb2ef4f 100644
--- a/test/simple/test-debug-port-cluster.js
+++ b/test/simple/test-debug-port-cluster.js
@@ -41,21 +41,12 @@ child.stderr.on('data', function(data) {
if (line === 'all workers are running') {
assertOutputLines();
- process.exit();
} else {
outputLines = outputLines.concat(lines);
}
});
-setTimeout(function testTimedOut() {
- assert(false, 'test timed out.');
-}, 3000);
-
-process.on('exit', function() {
- child.kill();
-});
-
-function assertOutputLines() {
+var assertOutputLines = common.mustCall(function() {
var expectedLines = [
'debugger listening on port ' + port,
'debugger listening on port ' + (port+1),
@@ -70,4 +61,4 @@ function assertOutputLines() {
assert.equal(outputLines.length, expectedLines.length)
for (var i = 0; i < expectedLines.length; i++)
assert.equal(outputLines[i], expectedLines[i]);
-}
+});