1
This commit is contained in:
parent
1a3ba56d9a
commit
810ad6f5cb
33 changed files with 10710 additions and 1087 deletions
|
|
@ -2,27 +2,57 @@ import { performance } from "node:perf_hooks";
|
|||
import { spawn } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const suites = [
|
||||
const defaultSuites = [
|
||||
"additional-generation-unit",
|
||||
"additional-generation-coverage-worker",
|
||||
"core",
|
||||
"terrain",
|
||||
"terrain-name",
|
||||
"admin",
|
||||
"patch",
|
||||
"patch-large",
|
||||
"determinism-114514",
|
||||
"determinism-12345",
|
||||
"determinism-54321",
|
||||
"determinism-777",
|
||||
"determinism-999",
|
||||
];
|
||||
const requestedSuites = String(process.env.TEST_SUITES || "").split(",").map((value) => value.trim()).filter(Boolean);
|
||||
const suites = requestedSuites.length ? requestedSuites : defaultSuites;
|
||||
const concurrency = Math.max(1, Math.min(2, Number(process.env.TEST_CONCURRENCY) || 1));
|
||||
const timeoutMs = 180_000;
|
||||
// Full-map shards can briefly peak at several hundred MB. CI may opt into a
|
||||
// handoff delay when its runtime needs extra time to reclaim a completed child.
|
||||
const suiteCooldownMs = Math.max(0, Number(process.env.TEST_SUITE_COOLDOWN_MS ?? 0));
|
||||
const suiteTimeoutMs = {
|
||||
"additional-generation-unit": 180_000,
|
||||
"additional-generation-coverage-worker": 120_000,
|
||||
core: 360_000,
|
||||
terrain: 600_000,
|
||||
"terrain-name": 240_000,
|
||||
admin: 300_000,
|
||||
patch: 300_000,
|
||||
"patch-large": 600_000,
|
||||
};
|
||||
const defaultTimeoutMs = 240_000;
|
||||
const maxOutputBytes = 32 * 1024 * 1024;
|
||||
const cwd = fileURLToPath(new URL(".", import.meta.url));
|
||||
const testFile = fileURLToPath(new URL("./test.js", import.meta.url));
|
||||
const additionalUnitFile = fileURLToPath(new URL("./additional-generation-unit.mjs", import.meta.url));
|
||||
const additionalCoverageWorkerFile = fileURLToPath(new URL("./additional-generation-coverage-worker.mjs", import.meta.url));
|
||||
|
||||
function runSuite(suite) {
|
||||
return new Promise((resolve) => {
|
||||
const timeoutMs = suiteTimeoutMs[suite] || defaultTimeoutMs;
|
||||
const started = performance.now();
|
||||
console.error(`[test-all] start ${suite}`);
|
||||
const child = spawn(process.execPath, [testFile, `--suite=${suite}`], {
|
||||
const standaloneFile = suite === "additional-generation-unit"
|
||||
? additionalUnitFile
|
||||
: suite === "additional-generation-coverage-worker"
|
||||
? additionalCoverageWorkerFile
|
||||
: null;
|
||||
const commandFile = standaloneFile || testFile;
|
||||
const commandArgs = standaloneFile ? [commandFile] : [commandFile, `--suite=${suite}`];
|
||||
const child = spawn(process.execPath, commandArgs, {
|
||||
cwd,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
|
|
@ -112,6 +142,9 @@ async function worker() {
|
|||
const suite = queue.shift();
|
||||
if (!suite) return;
|
||||
completed.push(await runSuite(suite));
|
||||
if (suiteCooldownMs > 0 && queue.length > 0) {
|
||||
await new Promise((resolve) => setTimeout(resolve, suiteCooldownMs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,17 +159,16 @@ const failures = completed.reduce(
|
|||
const infrastructureFailure = completed.some(
|
||||
(row) => row.status !== 0 || row.signal || row.timedOut || row.outputOverflow || row.infrastructureError,
|
||||
);
|
||||
const underThreeMinutes = wallSeconds < 180 && completed.every(
|
||||
(row) => row.seconds < 180 && !row.timedOut,
|
||||
);
|
||||
const withinSuiteBudgets = completed.every((row) => !row.timedOut);
|
||||
|
||||
const result = {
|
||||
underThreeMinutes,
|
||||
withinSuiteBudgets,
|
||||
wallSeconds,
|
||||
concurrency,
|
||||
suiteCooldownMs,
|
||||
failures,
|
||||
infrastructureFailure,
|
||||
suites: completed,
|
||||
};
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
if (!underThreeMinutes || infrastructureFailure || failures > 0) process.exitCode = 1;
|
||||
if (!withinSuiteBudgets || infrastructureFailure || failures > 0) process.exitCode = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue