2016-05-05 01:03:25 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
2017-05-07 14:10:32 +02:00
|
|
|
common.skipIfInspectorDisabled();
|
2016-05-05 01:03:25 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
const spawn = require('child_process').spawn;
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
let buffer = '';
|
2016-05-05 01:03:25 +02:00
|
|
|
|
2019-03-22 03:44:26 +01:00
|
|
|
// Connect to debug agent
|
2017-01-08 13:19:00 +00:00
|
|
|
const interfacer = spawn(process.execPath, ['debug', '-p', '655555']);
|
2016-05-05 01:03:25 +02:00
|
|
|
|
|
|
|
interfacer.stdout.setEncoding('utf-8');
|
|
|
|
interfacer.stderr.setEncoding('utf-8');
|
2017-04-30 15:54:18 -07:00
|
|
|
const onData = (data) => {
|
2016-05-05 01:03:25 +02:00
|
|
|
data = (buffer + data).split('\n');
|
|
|
|
buffer = data.pop();
|
|
|
|
data.forEach(function(line) {
|
|
|
|
interfacer.emit('line', line);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
interfacer.stdout.on('data', onData);
|
|
|
|
interfacer.stderr.on('data', onData);
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
let lineCount = 0;
|
2016-05-05 01:03:25 +02:00
|
|
|
interfacer.on('line', function(line) {
|
2017-01-08 13:19:00 +00:00
|
|
|
let expected;
|
2016-05-05 01:03:25 +02:00
|
|
|
const pid = interfacer.pid;
|
2017-04-30 15:54:18 -07:00
|
|
|
switch (++lineCount) {
|
|
|
|
case 1:
|
|
|
|
expected =
|
|
|
|
new RegExp(`^\\(node:${pid}\\) \\[DEP0068\\] DeprecationWarning: `);
|
2020-04-12 18:11:14 +02:00
|
|
|
assert.match(line, expected);
|
2017-04-30 15:54:18 -07:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-04-12 18:11:14 +02:00
|
|
|
assert.match(line, /Use `node --trace-deprecation \.\.\.` to show where /);
|
|
|
|
break;
|
|
|
|
case 3:
|
2017-04-30 15:54:18 -07:00
|
|
|
// Doesn't currently work on Windows.
|
|
|
|
if (!common.isWindows) {
|
|
|
|
expected = "Target process: 655555 doesn't exist.";
|
|
|
|
assert.strictEqual(line, expected);
|
|
|
|
}
|
|
|
|
break;
|
2016-05-05 01:03:25 +02:00
|
|
|
|
2017-04-30 15:54:18 -07:00
|
|
|
default:
|
|
|
|
if (!common.isWindows)
|
|
|
|
assert.fail(`unexpected line received: ${line}`);
|
2016-05-05 01:03:25 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
interfacer.on('exit', function(code, signal) {
|
2016-10-10 18:07:43 +01:00
|
|
|
assert.strictEqual(code, 1, `Got unexpected code: ${code}`);
|
2017-04-30 15:54:18 -07:00
|
|
|
if (!common.isWindows) {
|
2020-04-12 18:11:14 +02:00
|
|
|
assert.strictEqual(lineCount, 3);
|
2017-04-30 15:54:18 -07:00
|
|
|
}
|
2016-05-05 01:03:25 +02:00
|
|
|
});
|