Files
node/test/disabled/test-debugger-pid.js
T
Ali Ijaz Sheikh a235ccd168 src,test: debug is now an alias for inspect
`node debug` is now an alias of `node inspect`. This is intended to be
a minimal change – it does not get rid of the the debugger code. That
can be done in a follow-on.

PR-URL: https://github.com/nodejs/node/pull/11441
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: joshgav - Josh Gavant <josh.gavant@outlook.com>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
2017-04-11 17:58:26 -07:00

51 lines
1.3 KiB
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
let buffer = '';
// connect to debug agent
const interfacer = spawn(process.execPath, ['debug', '-p', '655555']);
console.error(process.execPath, 'debug', '-p', '655555');
interfacer.stdout.setEncoding('utf-8');
interfacer.stderr.setEncoding('utf-8');
const onData = function(data) {
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);
let lineCount = 0;
interfacer.on('line', function(line) {
let expected;
const pid = interfacer.pid;
if (common.isWindows) {
switch (++lineCount) {
case 1:
line = line.replace(/^(debug> *)+/, '');
const msg = 'There was an internal error in Node\'s debugger. ' +
'Please report this bug.';
expected = `(node:${pid}) ${msg}`;
break;
default:
return;
}
} else {
line = line.replace(/^(debug> *)+/, '');
expected = `(node:${pid}) Target process: 655555 doesn't exist.`;
}
assert.strictEqual(expected, line);
});
interfacer.on('exit', function(code, signal) {
assert.strictEqual(code, 1, `Got unexpected code: ${code}`);
});