summaryrefslogtreecommitdiff
path: root/tools/wpt.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-04-13 16:03:15 +0200
committerGitHub <noreply@github.com>2023-04-13 10:03:15 -0400
commit52d235391ca31a032387bae94a7edd132ac29343 (patch)
tree40ee408d0c350b1da89f4796d5476ba31f8a05ac /tools/wpt.ts
parent738bdebe13e8ba319997afb0d872118408ec3b6f (diff)
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.
Diffstat (limited to 'tools/wpt.ts')
-rwxr-xr-xtools/wpt.ts25
1 files changed, 20 insertions, 5 deletions
diff --git a/tools/wpt.ts b/tools/wpt.ts
index a216e84b0..a3426c5b8 100755
--- a/tools/wpt.ts
+++ b/tools/wpt.ts
@@ -217,7 +217,7 @@ async function run() {
await Deno.writeTextFile(wptreport, JSON.stringify(report));
}
- const code = reportFinal(results);
+ const code = reportFinal(results, endTime - startTime);
Deno.exit(code);
}
@@ -325,6 +325,7 @@ function assertAllExpectationsHaveTests(
async function update() {
assert(Array.isArray(rest), "filter must be array");
+ const startTime = new Date().getTime();
const tests = discoverTestsToRun(rest.length == 0 ? undefined : rest, true);
console.log(`Going to run ${tests.length} test files.`);
@@ -346,6 +347,7 @@ async function update() {
return results;
});
+ const endTime = new Date().getTime();
if (json) {
await Deno.writeTextFile(json, JSON.stringify(results));
@@ -394,7 +396,7 @@ async function update() {
saveExpectation(currentExpectation);
- reportFinal(results);
+ reportFinal(results, endTime - startTime);
console.log(blue("Updated expectation.json to match reality."));
@@ -428,6 +430,7 @@ function insertExpectation(
function reportFinal(
results: { test: TestToRun; result: TestResult }[],
+ duration: number,
): number {
const finalTotalCount = results.length;
let finalFailedCount = 0;
@@ -509,7 +512,7 @@ function reportFinal(
console.log(
`\nfinal result: ${
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;
@@ -564,7 +567,7 @@ function reportVariation(result: TestResult, expectation: boolean | string[]) {
console.log(
`\nfile result: ${
expectFail ? yellow("failed (expected)") : red("failed")
- }. ${failReason}\n`,
+ }. ${failReason} (${formatDuration(result.duration)})\n`,
);
return;
}
@@ -601,7 +604,9 @@ function reportVariation(result: TestResult, expectation: boolean | string[]) {
console.log(
`\nfile result: ${
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);
}
+
+function formatDuration(duration: number): string {
+ if (duration >= 5000) {
+ return red(`${duration}ms`);
+ } else if (duration >= 1000) {
+ return yellow(`${duration}ms`);
+ } else {
+ return `${duration}ms`;
+ }
+}