1'use strict'; 2const common = require('../common'); 3common.skipIfInspectorDisabled(); 4const assert = require('assert'); 5const spawn = require('child_process').spawn; 6 7let buffer = ''; 8 9// Connect to debug agent 10const interfacer = spawn(process.execPath, ['debug', '-p', '655555']); 11 12interfacer.stdout.setEncoding('utf-8'); 13interfacer.stderr.setEncoding('utf-8'); 14const onData = (data) => { 15 data = (buffer + data).split('\n'); 16 buffer = data.pop(); 17 data.forEach(function(line) { 18 interfacer.emit('line', line); 19 }); 20}; 21interfacer.stdout.on('data', onData); 22interfacer.stderr.on('data', onData); 23 24let lineCount = 0; 25interfacer.on('line', function(line) { 26 let expected; 27 const pid = interfacer.pid; 28 switch (++lineCount) { 29 case 1: 30 expected = 31 new RegExp(`^\\(node:${pid}\\) \\[DEP0068\\] DeprecationWarning: `); 32 assert.match(line, expected); 33 break; 34 case 2: 35 assert.match(line, /Use `node --trace-deprecation \.\.\.` to show where /); 36 break; 37 case 3: 38 // Doesn't currently work on Windows. 39 if (!common.isWindows) { 40 expected = "Target process: 655555 doesn't exist."; 41 assert.strictEqual(line, expected); 42 } 43 break; 44 45 default: 46 if (!common.isWindows) 47 assert.fail(`unexpected line received: ${line}`); 48 } 49}); 50 51interfacer.on('exit', function(code, signal) { 52 assert.strictEqual(code, 1, `Got unexpected code: ${code}`); 53 if (!common.isWindows) { 54 assert.strictEqual(lineCount, 3); 55 } 56}); 57