Skip to content
This repository was archived by the owner on May 30, 2019. It is now read-only.

Commit 1569a38

Browse files
committedApr 16, 2018
Improve tester output
1 parent ba602d9 commit 1569a38

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed
 

‎tools/tester.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,14 @@ function filter(name: string): boolean {
8686
}
8787

8888
const readline = IS_NODE ? require("readline") : null;
89-
const format = IS_NODE ? require("util").format : null;
9089
function log(...args) {
91-
if (IS_NODE) {
92-
if (process.stdout.isTTY) {
93-
readline.clearLine(process.stdout, 0);
94-
readline.cursorTo(process.stdout, 0, null);
95-
}
96-
process.stdout.write(format(...args));
97-
} else {
98-
console.log(...args);
90+
if (IS_NODE && process.stdout.isTTY) {
91+
// Clear second to last line.
92+
readline.cursorTo(process.stdout, 0, null);
93+
readline.moveCursor(process.stdout, null, -1);
94+
readline.clearLine(process.stdout, 0);
9995
}
96+
console.log(...args);
10097
}
10198

10299
async function runTests() {
@@ -115,7 +112,7 @@ async function runTests() {
115112
await fn();
116113
passed++;
117114
} catch (e) {
118-
console.error("\n\nTest FAIL", name);
115+
console.error("\nTest FAIL", name);
119116
console.error((e && e.stack) || e);
120117
failed++;
121118
if (exitOnFail) {
@@ -125,7 +122,7 @@ async function runTests() {
125122
}
126123
}
127124

128-
console.log(`\n\nDONE. Test passed: ${passed}, failed: ${failed}`);
125+
console.log(`\nDONE. Test passed: ${passed}, failed: ${failed}`);
129126

130127
if (failed === 0) {
131128
// All good.

0 commit comments

Comments
 (0)
This repository has been archived.