Skip to content

Commit 577e132

Browse files
santigimenoevanlucas
authored andcommitted
test: fix test-debugger-pid
The current format that prints the process PID before the actual message. Adapt the test so it also passes on Windows, that emits a different message from the rest of platforms. Move the test to parallel. PR-URL: #6584 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent d740624 commit 577e132

File tree

2 files changed

+54
-32
lines changed

2 files changed

+54
-32
lines changed

test/debugger/test-debugger-pid.js

-32
This file was deleted.

test/parallel/test-debugger-pid.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const spawn = require('child_process').spawn;
5+
6+
var buffer = '';
7+
8+
// connect to debug agent
9+
var interfacer = spawn(process.execPath, ['debug', '-p', '655555']);
10+
11+
console.error(process.execPath, 'debug', '-p', '655555');
12+
interfacer.stdout.setEncoding('utf-8');
13+
interfacer.stderr.setEncoding('utf-8');
14+
var onData = function(data) {
15+
data = (buffer + data).split('\n');
16+
buffer = data.pop();
17+
data.forEach(function(line) {
18+
interfacer.emit('line', line);
19+
});
20+
};
21+
interfacer.stdout.on('data', onData);
22+
interfacer.stderr.on('data', onData);
23+
24+
var lineCount = 0;
25+
interfacer.on('line', function(line) {
26+
var expected;
27+
const pid = interfacer.pid;
28+
if (common.isWindows) {
29+
switch (++lineCount) {
30+
case 1:
31+
line = line.replace(/^(debug> *)+/, '');
32+
var msg = 'There was an internal error in Node\'s debugger. ' +
33+
'Please report this bug.';
34+
expected = `(node:${pid}) ${msg}`;
35+
break;
36+
37+
case 2:
38+
expected = 'The parameter is incorrect.';
39+
break;
40+
41+
default:
42+
return;
43+
}
44+
} else {
45+
line = line.replace(/^(debug> *)+/, '');
46+
expected = `(node:${pid}) Target process: 655555 doesn\'t exist.`;
47+
}
48+
49+
assert.strictEqual(expected, line);
50+
});
51+
52+
interfacer.on('exit', function(code, signal) {
53+
assert.ok(code == 1, 'Got unexpected code: ' + code);
54+
});

0 commit comments

Comments
 (0)