Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/internal/test_runner/reporter/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ async function * tapReporter(source) {
yield `${indent(data.nesting)}# Subtest: ${tapEscape(data.name)}\n`;
break;
case 'test:stderr':
yield `# ${data.message}\n`;
break;
case 'test:stdout':
yield reportStdout(data.message);
break;
case 'test:diagnostic':
yield `${indent(data.nesting)}# ${tapEscape(data.message)}\n`;
break;
Expand Down Expand Up @@ -87,6 +91,17 @@ function reportDetails(nesting, data = kEmptyObject) {
return details;
}

function reportStdout(message) {
const lines = StringPrototypeSplit(message, kLineBreakRegExp);

const formattedLines = [];
for (let i = 0; i < lines.length; i++) {
ArrayPrototypePush(formattedLines, `# ${lines[i]}`);
}

return `${ArrayPrototypeJoin(formattedLines, '\n')}\n`;
}

const memo = new SafeMap();
function indent(nesting) {
let value = memo.get(nesting);
Expand Down
17 changes: 5 additions & 12 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ const {
ArrayPrototypeSlice,
ArrayPrototypeSome,
ArrayPrototypeSort,
hardenRegExp,
ObjectAssign,
PromisePrototypeThen,
SafePromiseAll,
SafePromiseAllReturnVoid,
SafePromiseAllSettledReturnVoid,
PromiseResolve,
RegExpPrototypeSymbolSplit,
SafeMap,
SafeSet,
StringPrototypeIndexOf,
Expand Down Expand Up @@ -75,7 +73,6 @@ const {
const kFilterArgs = ['--test', '--experimental-test-coverage', '--watch'];
const kFilterArgValues = ['--test-reporter', '--test-reporter-destination'];
const kDiagnosticsFilterArgs = ['tests', 'suites', 'pass', 'fail', 'cancelled', 'skipped', 'todo', 'duration_ms'];
const kSplitLine = hardenRegExp(/\r?\n/);

const kCanceledTests = new SafeSet()
.add(kCancelledByParent).add(kAborted).add(kTestTimeoutFailure);
Expand Down Expand Up @@ -280,15 +277,11 @@ class FileTest extends Test {
}

if (TypedArrayPrototypeGetLength(nonSerialized) > 0) {
const messages = RegExpPrototypeSymbolSplit(kSplitLine, nonSerialized.toString('utf-8'));
for (let i = 0; i < messages.length; i++) {
const message = messages[i];
this.addToReport({
__proto__: null,
type: 'test:stdout',
data: { __proto__: null, file: this.name, message },
});
}
this.addToReport({
__proto__: null,
type: 'test:stdout',
data: { __proto__: null, file: this.name, message: nonSerialized.toString('utf-8') },
});
}

while (bufferHead?.length >= kSerializedSizeHeader) {
Expand Down