Skip to content

Commit

Permalink
test: enable test-debugger-pid
Browse files Browse the repository at this point in the history
Now that `node debug` is an alias for `node inspect`, it's possible that
`node-debug-pid` can run reliably. Modify for current behavior and move
from `disabled` to `parallel`.
  • Loading branch information
Trott committed May 4, 2017
1 parent ff001c1 commit a5f99ae
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ 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) {
const onData = (data) => {
data = (buffer + data).split('\n');
buffer = data.pop();
data.forEach(function(line) {
Expand All @@ -25,26 +24,29 @@ 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;
switch (++lineCount) {
case 1:
expected =
new RegExp(`^\\(node:${pid}\\) \\[DEP0068\\] DeprecationWarning: `);
assert.ok(expected.test(line), `expected regexp match for ${line}`);
break;
case 2:
// Doesn't currently work on Windows.
if (!common.isWindows) {
expected = "Target process: 655555 doesn't exist.";
assert.strictEqual(line, expected);
}
break;

default:
return;
}
} else {
line = line.replace(/^(debug> *)+/, '');
expected = `(node:${pid}) Target process: 655555 doesn't exist.`;
default:
if (!common.isWindows)
assert.fail(`unexpected line received: ${line}`);
}

assert.strictEqual(expected, line);
});

interfacer.on('exit', function(code, signal) {
assert.strictEqual(code, 1, `Got unexpected code: ${code}`);
if (!common.isWindows) {
assert.strictEqual(lineCount, 2);
}
});

0 comments on commit a5f99ae

Please sign in to comment.