summaryrefslogtreecommitdiff
path: root/test/parallel/test-debugger-pid.js
blob: 157939c05c73fe31e6c3eda8973233c947829f3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();

if (common.isWindows)
  common.skip('unsupported function on windows');

const assert = require('assert');
const spawn = require('child_process').spawn;

let buffer = '';

// Connect to debug agent
const interfacer = spawn(process.execPath, ['inspect', '-p', '655555']);

interfacer.stdout.setEncoding('utf-8');
interfacer.stderr.setEncoding('utf-8');
const onData = (data) => {
  data = (buffer + data).split('\n');
  buffer = data.pop();
  data.forEach((line) => interfacer.emit('line', line));
};
interfacer.stdout.on('data', onData);
interfacer.stderr.on('data', onData);

interfacer.on('line', common.mustCall((line) => {
  assert.strictEqual(line, 'Target process: 655555 doesn\'t exist.');
}));