| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e5f4367 commit a368ea6
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,13 @@ | |||
| 1 | - var http = require('http'); | ||
| 2 | - var cluster = require('cluster'); | ||
| 3 | - var common = require('../../common'); | ||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const http = require('http'); | ||
| 4 | + const cluster = require('cluster'); | ||
| 4 | 5 | ||
| 5 | 6 | function handleRequest(request, response) { | |
| 6 | 7 | response.end('hello world\n'); | |
| 7 | 8 | } | |
| 8 | 9 | ||
| 9 | - var NUMBER_OF_WORKERS = 2; | ||
| 10 | + const NUMBER_OF_WORKERS = 2; | ||
| 10 | 11 | var workersOnline = 0; | |
| 11 | 12 | ||
| 12 | 13 | if (cluster.isMaster) { | |
@@ -18,7 +19,7 @@ if (cluster.isMaster) { | |||
| 18 | 19 | ||
| 19 | 20 | process.on('message', function(msg) { | |
| 20 | 21 | if (msg.type === 'getpids') { | |
| 21 | - var pids = []; | ||
| 22 | + const pids = []; | ||
| 22 | 23 | pids.push(process.pid); | |
| 23 | 24 | for (var key in cluster.workers) | |
| 24 | 25 | pids.push(cluster.workers[key].process.pid); | |
@@ -30,6 +31,6 @@ if (cluster.isMaster) { | |||
| 30 | 31 | cluster.fork(); | |
| 31 | 32 | } | |
| 32 | 33 | } else { | |
| 33 | - var server = http.createServer(handleRequest); | ||
| 34 | - server.listen(common.PORT); | ||
| 34 | + const server = http.createServer(handleRequest); | ||
| 35 | + server.listen(0); | ||
| 35 | 36 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,21 +1,23 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var common = require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var spawn = require('child_process').spawn; | ||
| 5 | 2 | ||
| 6 | - var port = common.PORT + 1; // The fixture uses common.PORT. | ||
| 7 | - var args = ['--debug-port=' + port, | ||
| 8 | - common.fixturesDir + '/clustered-server/app.js']; | ||
| 9 | - var options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] }; | ||
| 10 | - var child = spawn(process.execPath, args, options); | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const spawn = require('child_process').spawn; | ||
| 6 | + const path = require('path'); | ||
| 11 | 7 | ||
| 12 | - var outputLines = []; | ||
| 8 | + const port = common.PORT; | ||
| 9 | + const serverPath = path.join(common.fixturesDir, 'clustered-server', 'app.js'); | ||
| 10 | + const args = [`--debug-port=${port}`, serverPath]; | ||
| 11 | + const options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] }; | ||
| 12 | + const child = spawn(process.execPath, args, options); | ||
| 13 | + | ||
| 14 | + const outputLines = []; | ||
| 13 | 15 | var waitingForDebuggers = false; | |
| 14 | 16 | ||
| 15 | - var pids = null; | ||
| 17 | + var pids; | ||
| 16 | 18 | ||
| 17 | 19 | child.stderr.on('data', function(data) { | |
| 18 | - var lines = data.toString().replace(/\r/g, '').trim().split('\n'); | ||
| 20 | + const lines = data.toString().replace(/\r/g, '').trim().split('\n'); | ||
| 19 | 21 | ||
| 20 | 22 | lines.forEach(function(line) { | |
| 21 | 23 | console.log('> ' + line); | |
@@ -40,7 +42,7 @@ child.stderr.on('data', function(data) { | |||
| 40 | 42 | } | |
| 41 | 43 | ||
| 42 | 44 | }); | |
| 43 | - if (outputLines.length >= expectedLines.length) | ||
| 45 | + if (outputLines.length === expectedLines.length) | ||
| 44 | 46 | onNoMoreLines(); | |
| 45 | 47 | }); | |
| 46 | 48 | ||
@@ -50,7 +52,7 @@ function onNoMoreLines() { | |||
| 50 | 52 | } | |
| 51 | 53 | ||
| 52 | 54 | setTimeout(function testTimedOut() { | |
| 53 | - assert(false, 'test timed out.'); | ||
| 55 | + common.fail('test timed out'); | ||
| 54 | 56 | }, common.platformTimeout(4000)).unref(); | |
| 55 | 57 | ||
| 56 | 58 | process.on('exit', function onExit() { | |
@@ -61,7 +63,7 @@ process.on('exit', function onExit() { | |||
| 61 | 63 | }); | |
| 62 | 64 | }); | |
| 63 | 65 | ||
| 64 | - var expectedLines = [ | ||
| 66 | + const expectedLines = [ | ||
| 65 | 67 | 'Starting debugger agent.', | |
| 66 | 68 | 'Debugger listening on port ' + (port + 0), | |
| 67 | 69 | 'Starting debugger agent.', | |
@@ -77,7 +79,5 @@ function assertOutputLines() { | |||
| 77 | 79 | outputLines.sort(); | |
| 78 | 80 | expectedLines.sort(); | |
| 79 | 81 | ||
| 80 | - assert.equal(outputLines.length, expectedLines.length); | ||
| 81 | - for (var i = 0; i < expectedLines.length; i++) | ||
| 82 | - assert.equal(outputLines[i], expectedLines[i]); | ||
| 82 | + assert.deepStrictEqual(outputLines, expectedLines); | ||
| 83 | 83 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments