mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
print out the failed tests after the summary (denoland/deno_std#554)
Original: ed1b9e0563
This commit is contained in:
parent
77a20ec119
commit
e933a8a0e1
1 changed files with 33 additions and 2 deletions
|
@ -138,6 +138,7 @@ export function test(
|
||||||
|
|
||||||
const RED_FAILED = red("FAILED");
|
const RED_FAILED = red("FAILED");
|
||||||
const GREEN_OK = green("OK");
|
const GREEN_OK = green("OK");
|
||||||
|
const RED_BG_FAIL = bgRed(" FAIL ");
|
||||||
|
|
||||||
interface TestStats {
|
interface TestStats {
|
||||||
filtered: number;
|
filtered: number;
|
||||||
|
@ -201,6 +202,17 @@ function report(result: TestResult): void {
|
||||||
result.printed = true;
|
result.printed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function printFailedSummary(results: TestResults): void {
|
||||||
|
results.cases.forEach(
|
||||||
|
(v): void => {
|
||||||
|
if (!v.ok) {
|
||||||
|
console.error(`${RED_BG_FAIL} ${red(v.name)}`);
|
||||||
|
console.error(v.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function printResults(
|
function printResults(
|
||||||
stats: TestStats,
|
stats: TestStats,
|
||||||
results: TestResults,
|
results: TestResults,
|
||||||
|
@ -220,7 +232,7 @@ function printResults(
|
||||||
}
|
}
|
||||||
// Attempting to match the output of Rust's test runner.
|
// Attempting to match the output of Rust's test runner.
|
||||||
print(
|
print(
|
||||||
`\ntest result: ${stats.failed ? RED_FAILED : GREEN_OK}. ` +
|
`\ntest result: ${stats.failed ? RED_BG_FAIL : GREEN_OK} ` +
|
||||||
`${stats.passed} passed; ${stats.failed} failed; ` +
|
`${stats.passed} passed; ${stats.failed} failed; ` +
|
||||||
`${stats.ignored} ignored; ${stats.measured} measured; ` +
|
`${stats.ignored} ignored; ${stats.measured} measured; ` +
|
||||||
`${stats.filtered} filtered out ` +
|
`${stats.filtered} filtered out ` +
|
||||||
|
@ -287,6 +299,7 @@ async function runTestsParallel(
|
||||||
|
|
||||||
async function runTestsSerial(
|
async function runTestsSerial(
|
||||||
stats: TestStats,
|
stats: TestStats,
|
||||||
|
results: TestResults,
|
||||||
tests: TestDefinition[],
|
tests: TestDefinition[],
|
||||||
exitOnFail: boolean,
|
exitOnFail: boolean,
|
||||||
disableLog: boolean
|
disableLog: boolean
|
||||||
|
@ -309,6 +322,14 @@ async function runTestsSerial(
|
||||||
print(
|
print(
|
||||||
GREEN_OK + " " + name + " " + promptTestTime(end - start, true)
|
GREEN_OK + " " + name + " " + promptTestTime(end - start, true)
|
||||||
);
|
);
|
||||||
|
results.cases.forEach(
|
||||||
|
(v): void => {
|
||||||
|
if (v.name === name) {
|
||||||
|
v.ok = true;
|
||||||
|
v.printed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (disableLog) {
|
if (disableLog) {
|
||||||
print(CLEAR_LINE, false);
|
print(CLEAR_LINE, false);
|
||||||
|
@ -316,6 +337,15 @@ async function runTestsSerial(
|
||||||
print(`${RED_FAILED} ${name}`);
|
print(`${RED_FAILED} ${name}`);
|
||||||
print(err.stack);
|
print(err.stack);
|
||||||
stats.failed++;
|
stats.failed++;
|
||||||
|
results.cases.forEach(
|
||||||
|
(v): void => {
|
||||||
|
if (v.name === name) {
|
||||||
|
v.error = err;
|
||||||
|
v.ok = false;
|
||||||
|
v.printed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
if (exitOnFail) {
|
if (exitOnFail) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +397,7 @@ export async function runTests({
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
await runTestsParallel(stats, results, tests, exitOnFail);
|
await runTestsParallel(stats, results, tests, exitOnFail);
|
||||||
} else {
|
} else {
|
||||||
await runTestsSerial(stats, tests, exitOnFail, disableLog);
|
await runTestsSerial(stats, results, tests, exitOnFail, disableLog);
|
||||||
}
|
}
|
||||||
const end = performance.now();
|
const end = performance.now();
|
||||||
if (disableLog) {
|
if (disableLog) {
|
||||||
|
@ -379,6 +409,7 @@ export async function runTests({
|
||||||
// promise rejections being swallowed.
|
// promise rejections being swallowed.
|
||||||
setTimeout((): void => {
|
setTimeout((): void => {
|
||||||
console.error(`There were ${stats.failed} test failures.`);
|
console.error(`There were ${stats.failed} test failures.`);
|
||||||
|
printFailedSummary(results);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue