From 51a1084455c14bf13e6a4d7f1458c3e12df9c3c0 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Sat, 6 May 2023 22:55:25 +0300 Subject: [PATCH 1/3] test: display dot report as wide as the terminal width --- lib/internal/test_runner/reporter/dot.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/internal/test_runner/reporter/dot.js b/lib/internal/test_runner/reporter/dot.js index 7dbba5a957894e..c0298fecc215ca 100644 --- a/lib/internal/test_runner/reporter/dot.js +++ b/lib/internal/test_runner/reporter/dot.js @@ -2,6 +2,7 @@ module.exports = async function* dot(source) { let count = 0; + let columns = getLineLength(); for await (const { type } of source) { if (type === 'test:pass') { yield '.'; @@ -9,9 +10,16 @@ module.exports = async function* dot(source) { 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) { yield '\n'; + + // Getting again in case the terminal was resized. + columns = getLineLength(); } } yield '\n'; }; + +function getLineLength() { + return Math.max(process.stdout.columns ?? 20, 20); +} From 1d8183391ad41c6157c312737b3baa08aa30bbd7 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Sat, 6 May 2023 22:56:06 +0300 Subject: [PATCH 2/3] fix eslint --- lib/internal/test_runner/reporter/dot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/test_runner/reporter/dot.js b/lib/internal/test_runner/reporter/dot.js index c0298fecc215ca..5924e2fd245074 100644 --- a/lib/internal/test_runner/reporter/dot.js +++ b/lib/internal/test_runner/reporter/dot.js @@ -1,4 +1,5 @@ 'use strict'; +const { MathMax } = primordials; module.exports = async function* dot(source) { let count = 0; @@ -21,5 +22,5 @@ module.exports = async function* dot(source) { }; function getLineLength() { - return Math.max(process.stdout.columns ?? 20, 20); + return MathMax(process.stdout.columns ?? 20, 20); } From ba64fd4a4f5f0ce4fe574f7e905abf9f66d6df0e Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 17 May 2023 00:07:57 +0300 Subject: [PATCH 3/3] test_runner: display dot report as wide as the terminal width --- .../test-runner/output/dot_output_custom_columns.js | 10 ++++++++++ .../output/dot_output_custom_columns.snapshot | 4 ++++ test/parallel/test-runner-output.mjs | 1 + 3 files changed, 15 insertions(+) create mode 100644 test/fixtures/test-runner/output/dot_output_custom_columns.js create mode 100644 test/fixtures/test-runner/output/dot_output_custom_columns.snapshot diff --git a/test/fixtures/test-runner/output/dot_output_custom_columns.js b/test/fixtures/test-runner/output/dot_output_custom_columns.js new file mode 100644 index 00000000000000..1a76d9c59b1b99 --- /dev/null +++ b/test/fixtures/test-runner/output/dot_output_custom_columns.js @@ -0,0 +1,10 @@ +// Flags: --test-reporter=dot +'use strict'; +process.stdout.columns = 30; + +require('../../../common'); +const test = require('node:test'); + +for (let i = 0; i < 100; i++) { + test(i + ' example', () => {}); +} \ No newline at end of file diff --git a/test/fixtures/test-runner/output/dot_output_custom_columns.snapshot b/test/fixtures/test-runner/output/dot_output_custom_columns.snapshot new file mode 100644 index 00000000000000..00a76aa7f54c36 --- /dev/null +++ b/test/fixtures/test-runner/output/dot_output_custom_columns.snapshot @@ -0,0 +1,4 @@ +.............................. +.............................. +.............................. +.......... diff --git a/test/parallel/test-runner-output.mjs b/test/parallel/test-runner-output.mjs index d2fa06b4395095..bd8c9f1bd071ee 100644 --- a/test/parallel/test-runner-output.mjs +++ b/test/parallel/test-runner-output.mjs @@ -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 () => {