1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 04:48:52 -05:00

tests: parallelize test runs in wpt (#11306)

This commit is contained in:
Luca Casonato 2021-07-06 22:42:30 +02:00 committed by GitHub
parent bdfad23dd0
commit 7edb1d713c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,7 @@ import {
} from "./wpt/utils.ts"; } from "./wpt/utils.ts";
import { blue, bold, green, red, yellow } from "../test_util/std/fmt/colors.ts"; import { blue, bold, green, red, yellow } from "../test_util/std/fmt/colors.ts";
import { writeAll, writeAllSync } from "../test_util/std/io/util.ts"; import { writeAll, writeAllSync } from "../test_util/std/io/util.ts";
import { pooledMap } from "../test_util/std/async/pool.ts";
import { saveExpectation } from "./wpt/utils.ts"; import { saveExpectation } from "./wpt/utils.ts";
const command = Deno.args[0]; const command = Deno.args[0];
@ -152,17 +153,29 @@ async function run() {
console.log(`Going to run ${tests.length} test files.`); console.log(`Going to run ${tests.length} test files.`);
const results = await runWithTestUtil(false, async () => { const results = await runWithTestUtil(false, async () => {
const results = []; const results: { test: TestToRun; result: TestResult }[] = [];
for (const test of tests) { const cores = Deno.systemCpuInfo().cores ?? 4;
console.log(`${blue("-".repeat(40))}\n${bold(test.path)}\n`); const inParallel = !(cores === 1 || tests.length === 1);
const iter = pooledMap(cores, tests, async (test) => {
if (!inParallel) {
console.log(`${blue("-".repeat(40))}\n${bold(test.path)}\n`);
}
const result = await runSingleTest( const result = await runSingleTest(
test.url, test.url,
test.options, test.options,
createReportTestCase(test.expectation), inParallel ? () => {} : createReportTestCase(test.expectation),
); );
results.push({ test, result }); results.push({ test, result });
if (inParallel) {
console.log(`${blue("-".repeat(40))}\n${bold(test.path)}\n`);
}
reportVariation(result, test.expectation); reportVariation(result, test.expectation);
});
for await (const _ of iter) {
// do nothing
} }
return results; return results;