Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 938751b

Browse filesBrowse files
MoLowRafaelGSS
authored andcommitted
test: fix test-runner-inspect
PR-URL: #44620 Fixes: #44600 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent a28ae16 commit 938751b
Copy full SHA for 938751b

File tree

Expand file treeCollapse file tree

1 file changed

+13
-28
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-28
lines changed
Open diff view settings
Collapse file

‎lib/internal/test_runner/runner.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/runner.js
+13-28Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ const {
44
ArrayPrototypeFilter,
55
ArrayPrototypeIncludes,
66
ArrayPrototypeJoin,
7-
ArrayPrototypePop,
87
ArrayPrototypePush,
98
ArrayPrototypeSlice,
109
ArrayPrototypeSort,
1110
ObjectAssign,
1211
PromisePrototypeThen,
13-
RegExpPrototypeSymbolSplit,
1412
SafePromiseAll,
1513
SafeSet,
16-
StringPrototypeEndsWith,
1714
} = primordials;
1815

19-
const { Buffer } = require('buffer');
2016
const { spawn } = require('child_process');
2117
const { readdirSync, statSync } = require('fs');
18+
// TODO(aduh95): switch to internal/readline/interface when backporting to Node.js 16.x is no longer a concern.
19+
const { createInterface } = require('readline');
2220
const console = require('internal/console/global');
2321
const {
2422
codes: {
@@ -114,28 +112,6 @@ function getRunArgs({ path, inspectPort }) {
114112
return argv;
115113
}
116114

117-
function makeStderrCallback(callback) {
118-
if (!isUsingInspector()) {
119-
return callback;
120-
}
121-
let buffer = Buffer.alloc(0);
122-
return (data) => {
123-
callback(data);
124-
const newData = Buffer.concat([buffer, data]);
125-
const str = newData.toString('utf8');
126-
let lines = str;
127-
if (StringPrototypeEndsWith(lines, '\n')) {
128-
buffer = Buffer.alloc(0);
129-
} else {
130-
lines = RegExpPrototypeSymbolSplit(/\r?\n/, str);
131-
buffer = Buffer.from(ArrayPrototypePop(lines), 'utf8');
132-
lines = ArrayPrototypeJoin(lines, '\n');
133-
}
134-
if (isInspectorMessage(lines)) {
135-
process.stderr.write(lines);
136-
}
137-
};
138-
}
139115

140116
function runTestFile(path, root, inspectPort) {
141117
const subtest = root.createSubtest(Test, path, async (t) => {
@@ -151,9 +127,18 @@ function runTestFile(path, root, inspectPort) {
151127
err = error;
152128
});
153129

154-
child.stderr.on('data', makeStderrCallback((data) => {
130+
child.stderr.on('data', (data) => {
155131
stderr += data;
156-
}));
132+
});
133+
134+
if (isUsingInspector()) {
135+
const rl = createInterface({ input: child.stderr });
136+
rl.on('line', (line) => {
137+
if (isInspectorMessage(line)) {
138+
process.stderr.write(line + '\n');
139+
}
140+
});
141+
}
157142

158143
const { 0: { 0: code, 1: signal }, 1: stdout } = await SafePromiseAll([
159144
once(child, 'exit', { signal: t.signal }),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.