mirror of
https://github.com/nodejs/node.git
synced 2025-08-17 14:48:58 +02:00

PR-URL: https://github.com/nodejs/node/pull/55013 Fixes: https://github.com/nodejs/node/issues/55009 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
'use strict';
|
|
const {
|
|
ArrayPrototypePush,
|
|
MathMax,
|
|
} = primordials;
|
|
const colors = require('internal/util/colors');
|
|
const { formatTestReport } = require('internal/test_runner/reporter/utils');
|
|
|
|
module.exports = async function* dot(source) {
|
|
let count = 0;
|
|
let columns = getLineLength();
|
|
const failedTests = [];
|
|
for await (const { type, data } of source) {
|
|
if (type === 'test:pass') {
|
|
yield `${colors.green}.${colors.reset}`;
|
|
}
|
|
if (type === 'test:fail') {
|
|
yield `${colors.red}X${colors.reset}`;
|
|
ArrayPrototypePush(failedTests, data);
|
|
}
|
|
if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
|
|
yield '\n';
|
|
|
|
// Getting again in case the terminal was resized.
|
|
columns = getLineLength();
|
|
count = 0;
|
|
}
|
|
}
|
|
yield '\n';
|
|
if (failedTests.length > 0) {
|
|
yield `\n${colors.red}Failed tests:${colors.white}\n\n`;
|
|
for (const test of failedTests) {
|
|
yield formatTestReport('test:fail', test);
|
|
}
|
|
}
|
|
};
|
|
|
|
function getLineLength() {
|
|
return MathMax(process.stdout.columns ?? 20, 20);
|
|
}
|