mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
chore: add test duration to WPT (#18680)
To make it easier to debug which tests are slowing us down. Tests taking more than 5s have duration printed in red, taking more than 1s in yellow and less than 1s are printed without color.
This commit is contained in:
parent
0296b63369
commit
4fa39349b3
1 changed files with 20 additions and 5 deletions
25
tools/wpt.ts
25
tools/wpt.ts
|
@ -217,7 +217,7 @@ async function run() {
|
||||||
await Deno.writeTextFile(wptreport, JSON.stringify(report));
|
await Deno.writeTextFile(wptreport, JSON.stringify(report));
|
||||||
}
|
}
|
||||||
|
|
||||||
const code = reportFinal(results);
|
const code = reportFinal(results, endTime - startTime);
|
||||||
Deno.exit(code);
|
Deno.exit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,6 +325,7 @@ function assertAllExpectationsHaveTests(
|
||||||
|
|
||||||
async function update() {
|
async function update() {
|
||||||
assert(Array.isArray(rest), "filter must be array");
|
assert(Array.isArray(rest), "filter must be array");
|
||||||
|
const startTime = new Date().getTime();
|
||||||
const tests = discoverTestsToRun(rest.length == 0 ? undefined : rest, true);
|
const tests = discoverTestsToRun(rest.length == 0 ? undefined : rest, true);
|
||||||
console.log(`Going to run ${tests.length} test files.`);
|
console.log(`Going to run ${tests.length} test files.`);
|
||||||
|
|
||||||
|
@ -346,6 +347,7 @@ async function update() {
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
});
|
});
|
||||||
|
const endTime = new Date().getTime();
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
await Deno.writeTextFile(json, JSON.stringify(results));
|
await Deno.writeTextFile(json, JSON.stringify(results));
|
||||||
|
@ -394,7 +396,7 @@ async function update() {
|
||||||
|
|
||||||
saveExpectation(currentExpectation);
|
saveExpectation(currentExpectation);
|
||||||
|
|
||||||
reportFinal(results);
|
reportFinal(results, endTime - startTime);
|
||||||
|
|
||||||
console.log(blue("Updated expectation.json to match reality."));
|
console.log(blue("Updated expectation.json to match reality."));
|
||||||
|
|
||||||
|
@ -428,6 +430,7 @@ function insertExpectation(
|
||||||
|
|
||||||
function reportFinal(
|
function reportFinal(
|
||||||
results: { test: TestToRun; result: TestResult }[],
|
results: { test: TestToRun; result: TestResult }[],
|
||||||
|
duration: number,
|
||||||
): number {
|
): number {
|
||||||
const finalTotalCount = results.length;
|
const finalTotalCount = results.length;
|
||||||
let finalFailedCount = 0;
|
let finalFailedCount = 0;
|
||||||
|
@ -509,7 +512,7 @@ function reportFinal(
|
||||||
console.log(
|
console.log(
|
||||||
`\nfinal result: ${
|
`\nfinal result: ${
|
||||||
failed ? red("failed") : green("ok")
|
failed ? red("failed") : green("ok")
|
||||||
}. ${finalPassedCount} passed; ${finalFailedCount} failed; ${finalExpectedFailedAndFailedCount} expected failure; total ${finalTotalCount}\n`,
|
}. ${finalPassedCount} passed; ${finalFailedCount} failed; ${finalExpectedFailedAndFailedCount} expected failure; total ${finalTotalCount} (${duration}ms)\n`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return failed ? 1 : 0;
|
return failed ? 1 : 0;
|
||||||
|
@ -564,7 +567,7 @@ function reportVariation(result: TestResult, expectation: boolean | string[]) {
|
||||||
console.log(
|
console.log(
|
||||||
`\nfile result: ${
|
`\nfile result: ${
|
||||||
expectFail ? yellow("failed (expected)") : red("failed")
|
expectFail ? yellow("failed (expected)") : red("failed")
|
||||||
}. ${failReason}\n`,
|
}. ${failReason} (${formatDuration(result.duration)})\n`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -601,7 +604,9 @@ function reportVariation(result: TestResult, expectation: boolean | string[]) {
|
||||||
console.log(
|
console.log(
|
||||||
`\nfile result: ${
|
`\nfile result: ${
|
||||||
failedCount > 0 ? red("failed") : green("ok")
|
failedCount > 0 ? red("failed") : green("ok")
|
||||||
}. ${passedCount} passed; ${failedCount} failed; ${expectedFailedAndFailedCount} expected failure; total ${totalCount}\n`,
|
}. ${passedCount} passed; ${failedCount} failed; ${expectedFailedAndFailedCount} expected failure; total ${totalCount} (${
|
||||||
|
formatDuration(result.duration)
|
||||||
|
})\n`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,3 +764,13 @@ function partitionTests(tests: TestToRun[]): TestToRun[][] {
|
||||||
}
|
}
|
||||||
return Object.values(testsByKey);
|
return Object.values(testsByKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatDuration(duration: number): string {
|
||||||
|
if (duration >= 5000) {
|
||||||
|
return red(`${duration}ms`);
|
||||||
|
} else if (duration >= 1000) {
|
||||||
|
return yellow(`${duration}ms`);
|
||||||
|
} else {
|
||||||
|
return `${duration}ms`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue