1
Fork 0

Implement a finish method for the status_bar and some cleanup

This commit is contained in:
Stefan Schindler 2021-08-14 23:19:28 +02:00
parent c17628be18
commit 86fa21cda5

View file

@ -5,6 +5,7 @@
// ``` // ```
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const os = require('os');
const {Options, runTest} = require('browser-ui-test'); const {Options, runTest} = require('browser-ui-test');
function showHelp() { function showHelp() {
@ -78,7 +79,7 @@ function char_printer(n_tests) {
successful: function() { successful: function() {
current += 1; current += 1;
if (current % max_per_line === 0) { if (current % max_per_line === 0) {
process.stdout.write(`. (${current}/${n_tests})\n`); process.stdout.write(`. (${current}/${n_tests})${os.EOL}`);
} else { } else {
process.stdout.write("."); process.stdout.write(".");
} }
@ -86,11 +87,15 @@ function char_printer(n_tests) {
erroneous: function() { erroneous: function() {
current += 1; current += 1;
if (current % max_per_line === 0) { if (current % max_per_line === 0) {
process.stderr.write(`F (${current}/${n_tests})\n`); process.stderr.write(`F (${current}/${n_tests})${os.EOL}`);
} else { } else {
process.stderr.write("F"); process.stderr.write("F");
} }
}, },
finish: function() {
const spaces = " ".repeat(max_per_line - (current % max_per_line));
process.stdout.write(`${spaces} (${current}/${n_tests})${os.EOL}${os.EOL}`);
},
}; };
} }
@ -187,9 +192,10 @@ async function main(argv) {
await tests[i]; await tests[i];
} }
} }
if (!no_headless) {
await Promise.all(tests); await Promise.all(tests);
// final \n after the tests }
console.log("\n"); status_bar.finish();
if (debug === false) { if (debug === false) {
results.successful.sort(by_filename); results.successful.sort(by_filename);