@@ -8,10 +8,9 @@ let buffer = '';
88// connect to debug agent
99const interfacer = spawn ( process . execPath , [ 'debug' , '-p' , '655555' ] ) ;
1010
11- console . error ( process . execPath , 'debug' , '-p' , '655555' ) ;
1211interfacer . stdout . setEncoding ( 'utf-8' ) ;
1312interfacer . stderr . setEncoding ( 'utf-8' ) ;
14- const onData = function ( data ) {
13+ const onData = ( data ) => {
1514 data = ( buffer + data ) . split ( '\n' ) ;
1615 buffer = data . pop ( ) ;
1716 data . forEach ( function ( line ) {
@@ -25,26 +24,29 @@ let lineCount = 0;
2524interfacer . on ( 'line' , function ( line ) {
2625 let expected ;
2726 const pid = interfacer . pid ;
28- if ( common . isWindows ) {
29- switch ( ++ lineCount ) {
30- case 1 :
31- line = line . replace ( / ^ ( d e b u g > * ) + / , '' ) ;
32- const msg = 'There was an internal error in Node\'s debugger. ' +
33- 'Please report this bug.' ;
34- expected = `(node:${ pid } ) ${ msg } ` ;
35- break ;
27+ switch ( ++ lineCount ) {
28+ case 1 :
29+ expected =
30+ new RegExp ( `^\\(node:${ pid } \\) \\[DEP0068\\] DeprecationWarning: ` ) ;
31+ assert . ok ( expected . test ( line ) , `expected regexp match for ${ line } ` ) ;
32+ break ;
33+ case 2 :
34+ // Doesn't currently work on Windows.
35+ if ( ! common . isWindows ) {
36+ expected = "Target process: 655555 doesn't exist." ;
37+ assert . strictEqual ( line , expected ) ;
38+ }
39+ break ;
3640
37- default :
38- return ;
39- }
40- } else {
41- line = line . replace ( / ^ ( d e b u g > * ) + / , '' ) ;
42- expected = `(node:${ pid } ) Target process: 655555 doesn't exist.` ;
41+ default :
42+ if ( ! common . isWindows )
43+ assert . fail ( `unexpected line received: ${ line } ` ) ;
4344 }
44-
45- assert . strictEqual ( expected , line ) ;
4645} ) ;
4746
4847interfacer . on ( 'exit' , function ( code , signal ) {
4948 assert . strictEqual ( code , 1 , `Got unexpected code: ${ code } ` ) ;
49+ if ( ! common . isWindows ) {
50+ assert . strictEqual ( lineCount , 2 ) ;
51+ }
5052} ) ;
0 commit comments