From d55e07f6274d45a027885453ea9f80475e6d9393 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Wed, 10 May 2023 21:35:42 +0200 Subject: [PATCH] chore(core): Parallelize all WPT tests and reduce timeouts for expected failures (#19061) This speeds up WPT tests in two ways: 1. The `WebCryptoAPI` tests are slow, so create a parallel bucket for each individual test instead of one for all the `WebCryptoAPI` tests. 2. If a test is expected to fail, use a shorter timeout (1 minute rather than 4). --- tools/wpt.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tools/wpt.ts b/tools/wpt.ts index a3426c5b87..fe2a350b27 100755 --- a/tools/wpt.ts +++ b/tools/wpt.ts @@ -145,6 +145,18 @@ interface TestToRun { expectation: boolean | string[]; } +function getTestTimeout(test: TestToRun) { + if (Deno.env.get("CI")) { + // Don't give expected failures the full time + if (test.expectation === false) { + return { long: 60_000, default: 10_000 }; + } + return { long: 4 * 60_000, default: 4 * 60_000 }; + } + + return { long: 60_000, default: 10_000 }; +} + async function run() { const startTime = new Date().getTime(); assert(Array.isArray(rest), "filter must be array"); @@ -154,11 +166,11 @@ async function run() { expectation, ); assertAllExpectationsHaveTests(expectation, tests, rest); - console.log(`Going to run ${tests.length} test files.`); + const cores = navigator.hardwareConcurrency; + console.log(`Going to run ${tests.length} test files on ${cores} cores.`); const results = await runWithTestUtil(false, async () => { const results: { test: TestToRun; result: TestResult }[] = []; - const cores = navigator.hardwareConcurrency; const inParallel = !(cores === 1 || tests.length === 1); // ideally we would parallelize all tests, but we ran into some flakiness // on the CI, so here we're partitioning based on the start of the test path @@ -174,9 +186,7 @@ async function run() { test.options, inParallel ? () => {} : createReportTestCase(test.expectation), inspectBrk, - Deno.env.get("CI") - ? { long: 4 * 60_000, default: 4 * 60_000 } - : { long: 60_000, default: 10_000 }, + getTestTimeout(test), ); results.push({ test, result }); if (inParallel) { @@ -755,6 +765,11 @@ function discoverTestsToRun( function partitionTests(tests: TestToRun[]): TestToRun[][] { const testsByKey: { [key: string]: TestToRun[] } = {}; for (const test of tests) { + // Run all WebCryptoAPI tests in parallel + if (test.path.includes("/WebCryptoAPI")) { + testsByKey[test.path] = [test]; + continue; + } // Paths looks like: /fetch/corb/img-html-correctly-labeled.sub-ref.html const key = test.path.split("/")[1]; if (!(key in testsByKey)) {