GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner: display dot report as wide as the terminal width · nodejs/node@23d310b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/test_runner/reporter
    • dot.js
  • test
    • fixtures/test-runner/output
      • dot_output_custom_columns.js
      • dot_output_custom_columns.snapshot
    • parallel
      • test-runner-output.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/test_runner/reporter/dot.js‎

Copy file name to clipboard
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
'use strict';
2+
const { MathMax } = primordials;
23

34
module.exports = async function* dot(source) {
45
let count = 0;
6+
let columns = getLineLength();
57
for await (const { type } of source) {
68
if (type === 'test:pass') {
79
yield '.';
810
}
911
if (type === 'test:fail') {
1012
yield 'X';
1113
}
12-
if ((type === 'test:fail' || type === 'test:pass') && ++count % 20 === 0) {
14+
if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
1315
yield '\n';
16+
17+
// Getting again in case the terminal was resized.
18+
columns = getLineLength();
19+
count = 0;
1420
}
1521
}
1622
yield '\n';
1723
};
24+
25+
function getLineLength() {
26+
return MathMax(process.stdout.columns ?? 20, 20);
27+
}
Collapse file

‎test/fixtures/test-runner/output/dot_output_custom_columns.js‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Flags: --test-reporter=dot
2+
'use strict';
3+
process.stdout.columns = 30;
4+
5+
const test = require('node:test');
6+
const { setTimeout } = require('timers/promises');
7+
8+
for (let i = 0; i < 100; i++) {
9+
test(i + ' example', async () => {
10+
if (i === 0) {
11+
// So the reporter will run before all tests has started
12+
await setTimeout(10);
13+
}
14+
// resize
15+
if (i === 28)
16+
process.stdout.columns = 41;
17+
});
18+
}
Collapse file

‎test/fixtures/test-runner/output/dot_output_custom_columns.snapshot‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
..............................
2+
.........................................
3+
.............................
Collapse file

‎test/parallel/test-runner-output.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-output.mjs
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const tests = [
4646
{ name: 'test-runner/output/unresolved_promise.js' },
4747
{ name: 'test-runner/output/default_output.js', transform: specTransform, tty: true },
4848
{ name: 'test-runner/output/arbitrary-output.js' },
49+
{ name: 'test-runner/output/dot_output_custom_columns.js', transform: specTransform, tty: true },
4950
].map(({ name, tty, transform }) => ({
5051
name,
5152
fn: common.mustCall(async () => {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.