11'use strict' ;
2- var common = require ( '../common' ) ;
3- var assert = require ( 'assert' ) ;
4- var spawn = require ( 'child_process' ) . spawn ;
52
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' ) ;
117
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 = [ ] ;
1315var waitingForDebuggers = false ;
1416
15- var pids = null ;
17+ var pids ;
1618
1719child . 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' ) ;
1921
2022 lines . forEach ( function ( line ) {
2123 console . log ( '> ' + line ) ;
@@ -40,7 +42,7 @@ child.stderr.on('data', function(data) {
4042 }
4143
4244 } ) ;
43- if ( outputLines . length > = expectedLines . length )
45+ if ( outputLines . length == = expectedLines . length )
4446 onNoMoreLines ( ) ;
4547} ) ;
4648
@@ -50,7 +52,7 @@ function onNoMoreLines() {
5052}
5153
5254setTimeout ( function testTimedOut ( ) {
53- assert ( false , 'test timed out. ' ) ;
55+ common . fail ( 'test timed out' ) ;
5456} , common . platformTimeout ( 4000 ) ) . unref ( ) ;
5557
5658process . on ( 'exit' , function onExit ( ) {
@@ -61,7 +63,7 @@ process.on('exit', function onExit() {
6163 } ) ;
6264} ) ;
6365
64- var expectedLines = [
66+ const expectedLines = [
6567 'Starting debugger agent.' ,
6668 'Debugger listening on 127.0.0.1:' + ( port + 0 ) ,
6769 'Starting debugger agent.' ,
@@ -77,7 +79,5 @@ function assertOutputLines() {
7779 outputLines . sort ( ) ;
7880 expectedLines . sort ( ) ;
7981
80- assert . equal ( outputLines . length , expectedLines . length ) ;
81- for ( var i = 0 ; i < expectedLines . length ; i ++ )
82- assert ( expectedLines [ i ] . includes ( outputLines [ i ] ) ) ;
82+ assert . deepStrictEqual ( outputLines , expectedLines ) ;
8383}
0 commit comments