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.ok(expected.test(line), `expected regexp match for ${line}`); 33 break; 34 case 2: 35 // Doesn't currently work on Windows. 36 if (!common.isWindows) { 37 expected = "Target process: 655555 doesn't exist."; 38 assert.strictEqual(line, expected); 39 } 40 break; 41 42 default: 43 if (!common.isWindows) 44 assert.fail(`unexpected line received: ${line}`); 45 } 46}); 47 48interfacer.on('exit', function(code, signal) { 49 assert.strictEqual(code, 1, `Got unexpected code: ${code}`); 50 if (!common.isWindows) { 51 assert.strictEqual(lineCount, 2); 52 } 53}); 54