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
}
0 commit comments