Skip to content
Prev Previous commit
Next Next commit
primordials
  • Loading branch information
MoLow committed Sep 9, 2022
commit b07d5742a8d082cefafa5677c218264d4ee03eb9
11 changes: 7 additions & 4 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ const {
ArrayPrototypeFilter,
ArrayPrototypeIncludes,
ArrayPrototypeJoin,
ArrayPrototypePop,
ArrayPrototypePush,
ArrayPrototypeSlice,
ArrayPrototypeSort,
ObjectAssign,
PromisePrototypeThen,
RegExpPrototypeSymbolSplit,
SafePromiseAll,
SafeSet,
StringPrototypeEndsWith,
} = primordials;

const { Buffer } = require('buffer');
Expand Down Expand Up @@ -120,12 +123,12 @@ function makeStderrCallback(callback) {
callback(data);
const newData = Buffer.concat([buffer, data]);
const str = newData.toString('utf8');
let lines = str.split(/\r?\n/);
if (str.endsWith('\n'))
let lines = RegExpPrototypeSymbolSplit(/\r?\n/, str);
if (StringPrototypeEndsWith(str, '\n'))
buffer = Buffer.alloc(0);
else
buffer = Buffer.from(lines.pop(), 'utf8');
lines = lines.join('\n');
buffer = Buffer.from(ArrayPrototypePop(lines), 'utf8');
lines = ArrayPrototypeJoin(lines, '\n');
if (isInspectorMessage(lines)) {
process.stderr.write(lines);
}
Expand Down