test: overhaul deterministic suite architecture

This commit is contained in:
morluto
2026-07-29 22:00:38 +00:00
parent 7f2348619a
commit 513d9b1555
371 changed files with 30879 additions and 24389 deletions
+86 -79
View File
@@ -4,92 +4,87 @@ import { join } from "node:path";
import { defineConfig } from "vitest/config";
export const TEST_FILES = ["tests/**/*.test.ts"];
const IS_CONTINUOUS_INTEGRATION = process.env.CI === "true";
// Lazy MCP integration tests are memory-bound while Vite transforms tool families.
const MAX_TEST_WORKERS = 2;
const MAX_UNIT_TEST_WORKERS = 1;
const PROCESS_CAPTURE_TEST = "tests/processCapture.test.ts";
const CANONICAL_TEMPORARY_DIRECTORY = realpathSync(tmpdir());
export const SERIAL_INTEGRATION_TESTS = [
"tests/applicationWorkflowCli.test.ts",
"tests/browserCli.test.ts",
"tests/cliOutput.test.ts",
"tests/electronCli.test.ts",
"tests/javascriptArtifactReconstruction.test.ts",
PROCESS_CAPTURE_TEST,
"tests/runtime.test.ts",
const COVERAGE_ENABLED = process.argv.some((argument) =>
argument.startsWith("--coverage"),
);
export const MAX_TEST_WORKERS = Math.min(4, availableParallelism());
export const TEST_PROJECTS = [
{
name: "domain",
include: ["src/domain/**/*.test.ts"],
pool: "threads" as const,
maxWorkers: MAX_TEST_WORKERS,
},
{
name: "services",
include: ["src/application/**/*.test.ts"],
pool: "threads" as const,
maxWorkers: MAX_TEST_WORKERS,
},
{
name: "adapters",
include: [
"src/{artifacts,browser,dotnet,ghidra,hopper,native,process,reference,replay}/**/*.test.ts",
],
pool: "forks" as const,
maxWorkers: MAX_TEST_WORKERS,
},
{
name: "composition",
include: ["tests/composition/**/*.test.ts"],
pool: "threads" as const,
maxWorkers: MAX_TEST_WORKERS,
},
{
name: "boundary",
include: ["tests/boundary/**/*.test.ts"],
pool: "forks" as const,
maxWorkers: MAX_TEST_WORKERS,
},
{
name: "acceptance",
include: ["tests/acceptance/**/*.test.ts"],
pool: "forks" as const,
maxWorkers: 1,
},
{
name: "process-global",
include: ["tests/process-global/**/*.test.ts"],
pool: "forks" as const,
fileParallelism: false,
},
{
name: "conformance",
include: ["tests/conformance/**/*.test.ts"],
pool: "threads" as const,
maxWorkers: MAX_TEST_WORKERS,
},
{
name: "evaluation",
include: ["tests/evaluation/**/*.test.ts"],
pool: "threads" as const,
maxWorkers: MAX_TEST_WORKERS,
},
];
// Keep tests that launch child processes or production runtimes in the forks pool.
// In-memory MCP and filesystem-seam tests remain safe in the faster threads pool.
export const SUBPROCESS_TESTS = [
"tests/applicationWorkflowVerifier.test.ts",
"tests/bridgeLauncher.test.ts",
"tests/bridgeRegex.test.ts",
"tests/browserProcessStartup.test.ts",
"tests/cliPolicyCommands.test.ts",
"tests/cliSetup.test.ts",
"tests/dependencyInstall.test.ts",
"tests/dispatcher.test.ts",
"tests/ghidraClient.test.ts",
"tests/ghidraWindowsFixture.test.ts",
"tests/hopperClient.test.ts",
"tests/installScript.test.ts",
"tests/javascriptReplayWorker.test.ts",
"tests/javascriptRuntimeReconciliation.test.ts",
"tests/linuxPrivateDisplay.test.ts",
"tests/mcpDoctor.test.ts",
"tests/processCli.test.ts",
"tests/providerProcess.test.ts",
"tests/runtimeExecutableDiagnostics.test.ts",
"tests/scanTodos.test.ts",
"tests/sessionMcp.test.ts",
"tests/verifierRun.test.ts",
"tests/vitestConfiguration.test.ts",
];
const isolatedProjects = {
maxWorkers: Math.min(MAX_TEST_WORKERS, availableParallelism()),
projects: [
{
extends: true as const,
test: {
name: "parallel",
include: TEST_FILES,
exclude: [...SERIAL_INTEGRATION_TESTS, ...SUBPROCESS_TESTS],
pool: "threads",
maxWorkers: Math.min(MAX_UNIT_TEST_WORKERS, availableParallelism()),
sequence: { groupOrder: 0 },
},
},
{
extends: true as const,
test: {
name: "subprocess",
include: SUBPROCESS_TESTS,
pool: "forks",
maxWorkers: Math.min(MAX_TEST_WORKERS, availableParallelism()),
sequence: { groupOrder: 1 },
},
},
{
extends: true as const,
test: {
name: "serial-integration",
include: SERIAL_INTEGRATION_TESTS,
fileParallelism: false,
pool: "forks",
sequence: { groupOrder: 2 },
},
},
],
};
const projects = TEST_PROJECTS.map((project) => ({
extends: true as const,
test: project,
}));
export default defineConfig({
test: {
env: { TMPDIR: CANONICAL_TEMPORARY_DIRECTORY },
...isolatedProjects,
retry: IS_CONTINUOUS_INTEGRATION ? 2 : 0,
maxWorkers: MAX_TEST_WORKERS,
projects,
retry: 0,
reporters: ["default"],
// Boundary projects may compete with TypeScript, docs, and package checks
// under Turbo. Keep the deadline bounded while avoiding false failures from
// host-level CPU and filesystem contention.
testTimeout: COVERAGE_ENABLED ? 30_000 : 15_000,
coverage: {
enabled: false,
provider: "v8",
@@ -103,6 +98,18 @@ export default defineConfig({
branches: 60,
functions: 60,
lines: 68,
"src/domain/**": {
statements: 80,
branches: 75,
functions: 75,
lines: 80,
},
"src/contracts/**": {
statements: 85,
branches: 80,
functions: 80,
lines: 85,
},
},
reporter: ["text", "text-summary"],
},