@@ -8,10 +8,9 @@ let buffer = '';
8
8
// connect to debug agent
9
9
const interfacer = spawn ( process . execPath , [ 'debug' , '-p' , '655555' ] ) ;
10
10
11
- console . error ( process . execPath , 'debug' , '-p' , '655555' ) ;
12
11
interfacer . stdout . setEncoding ( 'utf-8' ) ;
13
12
interfacer . stderr . setEncoding ( 'utf-8' ) ;
14
- const onData = function ( data ) {
13
+ const onData = ( data ) => {
15
14
data = ( buffer + data ) . split ( '\n' ) ;
16
15
buffer = data . pop ( ) ;
17
16
data . forEach ( function ( line ) {
@@ -25,26 +24,29 @@ let lineCount = 0;
25
24
interfacer . on ( 'line' , function ( line ) {
26
25
let expected ;
27
26
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 ;
36
40
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 } ` ) ;
43
44
}
44
-
45
- assert . strictEqual ( expected , line ) ;
46
45
} ) ;
47
46
48
47
interfacer . on ( 'exit' , function ( code , signal ) {
49
48
assert . strictEqual ( code , 1 , `Got unexpected code: ${ code } ` ) ;
49
+ if ( ! common . isWindows ) {
50
+ assert . strictEqual ( lineCount , 2 ) ;
51
+ }
50
52
} ) ;
0 commit comments