|  | 
| 2 | 2 | const common = require('../common'); | 
| 3 | 3 | const assert = require('assert'); | 
| 4 | 4 | const spawn = require('child_process').spawn; | 
|  | 5 | +const os = require('os'); | 
| 5 | 6 | 
 | 
| 6 | 7 | const debugPort = common.PORT; | 
| 7 | 8 | const args = ['--interactive', '--debug-port=' + debugPort]; | 
| 8 | 9 | const childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] }; | 
| 9 | 10 | const child = spawn(process.execPath, args, childOptions); | 
| 10 | 11 | 
 | 
|  | 12 | +const reDeprecationWarning = new RegExp( | 
|  | 13 | +  /^\(node:\d+\) DeprecationWarning: /.source + | 
|  | 14 | +  /node --debug is deprecated. /.source + | 
|  | 15 | +  /Please use node --inspect instead.$/.source | 
|  | 16 | +); | 
|  | 17 | + | 
| 11 | 18 | child.stdin.write("process.send({ msg: 'childready' });\n"); | 
| 12 | 19 | 
 | 
| 13 | 20 | child.stderr.on('data', function(data) { | 
| @@ -37,12 +44,20 @@ function processStderrLine(line) { | 
| 37 | 44 | } | 
| 38 | 45 | 
 | 
| 39 | 46 | function assertOutputLines() { | 
| 40 |  | -  const expectedLines = [ | 
| 41 |  | -    'Starting debugger agent.', | 
| 42 |  | -    'Debugger listening on 127.0.0.1:' + debugPort, | 
|  | 47 | +  // need a var so can swap the first two lines in following | 
|  | 48 | +  // eslint-disable-next-line no-var | 
|  | 49 | +  var expectedLines = [ | 
|  | 50 | +    /^Starting debugger agent.$/, | 
|  | 51 | +    reDeprecationWarning, | 
|  | 52 | +    new RegExp(`^Debugger listening on 127.0.0.1:${debugPort}$`) | 
| 43 | 53 |   ]; | 
| 44 | 54 | 
 | 
|  | 55 | +  if (os.platform() === 'win32') { | 
|  | 56 | +    expectedLines[1] = expectedLines[0]; | 
|  | 57 | +    expectedLines[0] = reDeprecationWarning; | 
|  | 58 | +  } | 
|  | 59 | + | 
| 45 | 60 |   assert.strictEqual(outputLines.length, expectedLines.length); | 
| 46 | 61 |   for (let i = 0; i < expectedLines.length; i++) | 
| 47 |  | -    assert(expectedLines[i].includes(outputLines[i])); | 
|  | 62 | +    assert(expectedLines[i].test(outputLines[i])); | 
| 48 | 63 | } | 
0 commit comments