Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: display dot report as wide as the terminal width #48038

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion lib/internal/test_runner/reporter/dot.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
'use strict';
const { MathMax } = primordials;

module.exports = async function* dot(source) {
let count = 0;
let columns = getLineLength();
for await (const { type } of source) {
if (type === 'test:pass') {
yield '.';
}
if (type === 'test:fail') {
yield 'X';
}
if ((type === 'test:fail' || type === 'test:pass') && ++count % 20 === 0) {
if ((type === 'test:fail' || type === 'test:pass') && ++count % columns === 0) {
MoLow marked this conversation as resolved.
Show resolved Hide resolved
rluvaton marked this conversation as resolved.
Show resolved Hide resolved
yield '\n';

// Getting again in case the terminal was resized.
columns = getLineLength();
}
}
yield '\n';
};

function getLineLength() {
return MathMax(process.stdout.columns ?? 20, 20);
}
10 changes: 10 additions & 0 deletions test/fixtures/test-runner/output/dot_output_custom_columns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Flags: --test-reporter=dot
'use strict';
process.stdout.columns = 30;

require('../../../common');
rluvaton marked this conversation as resolved.
Show resolved Hide resolved
const test = require('node:test');

for (let i = 0; i < 100; i++) {
test(i + ' example', () => {});
MoLow marked this conversation as resolved.
Show resolved Hide resolved
}
rluvaton marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
..............................
..............................
..............................
..........
1 change: 1 addition & 0 deletions test/parallel/test-runner-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const tests = [
{ name: 'test-runner/output/unresolved_promise.js' },
{ name: 'test-runner/output/default_output.js', transform: specTransform, tty: true },
{ name: 'test-runner/output/arbitrary-output.js' },
{ name: 'test-runner/output/dot_output_custom_columns.js', transform: specTransform, tty: true },
].map(({ name, tty, transform }) => ({
name,
fn: common.mustCall(async () => {
Expand Down