mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
9 years ago
|
'use strict';
|
||
|
const common = require('../common');
|
||
|
const assert = require('assert');
|
||
|
const spawn = require('child_process').spawn;
|
||
|
|
||
8 years ago
|
let buffer = '';
|
||
9 years ago
|
|
||
|
// connect to debug agent
|
||
8 years ago
|
const interfacer = spawn(process.execPath, ['debug', '-p', '655555']);
|
||
9 years ago
|
|
||
|
console.error(process.execPath, 'debug', '-p', '655555');
|
||
|
interfacer.stdout.setEncoding('utf-8');
|
||
|
interfacer.stderr.setEncoding('utf-8');
|
||
8 years ago
|
const onData = function(data) {
|
||
9 years ago
|
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);
|
||
|
|
||
8 years ago
|
let lineCount = 0;
|
||
9 years ago
|
interfacer.on('line', function(line) {
|
||
8 years ago
|
let expected;
|
||
9 years ago
|
const pid = interfacer.pid;
|
||
|
if (common.isWindows) {
|
||
|
switch (++lineCount) {
|
||
|
case 1:
|
||
|
line = line.replace(/^(debug> *)+/, '');
|
||
8 years ago
|
const msg = 'There was an internal error in Node\'s debugger. ' +
|
||
|
'Please report this bug.';
|
||
9 years ago
|
expected = `(node:${pid}) ${msg}`;
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
line = line.replace(/^(debug> *)+/, '');
|
||
8 years ago
|
expected = `(node:${pid}) Target process: 655555 doesn't exist.`;
|
||
9 years ago
|
}
|
||
|
|
||
|
assert.strictEqual(expected, line);
|
||
|
});
|
||
|
|
||
|
interfacer.on('exit', function(code, signal) {
|
||
8 years ago
|
assert.strictEqual(code, 1, `Got unexpected code: ${code}`);
|
||
9 years ago
|
});
|