Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
406
scripts/test-projects.mjs
Normal file
406
scripts/test-projects.mjs
Normal file
@@ -0,0 +1,406 @@
|
||||
// Dispatches Vitest project shards for explicit targets, changed files, or the
|
||||
// full local suite.
|
||||
import fs from "node:fs";
|
||||
import { performance } from "node:perf_hooks";
|
||||
import { formatMs } from "./lib/check-timing-summary.mjs";
|
||||
import { acquireLocalHeavyCheckLockSync } from "./lib/local-heavy-check-runtime.mjs";
|
||||
import {
|
||||
isCiLikeEnv,
|
||||
resolveLocalFullSuiteProfile,
|
||||
resolveLocalVitestEnv,
|
||||
} from "./lib/vitest-local-scheduling.mjs";
|
||||
import {
|
||||
createShardTimingSample,
|
||||
readShardTimings,
|
||||
writeShardTimings,
|
||||
} from "./lib/vitest-shard-timings.mjs";
|
||||
import {
|
||||
resolveVitestCliEntry,
|
||||
resolveVitestNodeArgs,
|
||||
resolveVitestSpawnParams,
|
||||
spawnWatchedVitestProcess,
|
||||
} from "./run-vitest.mjs";
|
||||
import {
|
||||
applyDefaultMultiSpecVitestCachePaths,
|
||||
applyDefaultVitestNoOutputTimeout,
|
||||
applyParallelVitestCachePaths,
|
||||
buildFullSuiteVitestRunPlans,
|
||||
createVitestRunSpecs,
|
||||
findUnmatchedExplicitTestTargets,
|
||||
formatFailedShardDigest,
|
||||
formatNoChangedTestTargetLines,
|
||||
listFullExtensionVitestProjectConfigs,
|
||||
orderFullSuiteSpecsForParallelRun,
|
||||
parseTestProjectsArgs,
|
||||
resolveParallelFullSuiteConcurrency,
|
||||
resolveChangedTestTargetPlanForArgs,
|
||||
resolveChangedTargetArgs,
|
||||
shouldAcquireLocalHeavyCheckLock,
|
||||
shouldRetryVitestNoOutputTimeout,
|
||||
writeVitestIncludeFile,
|
||||
} from "./test-projects.test-support.mjs";
|
||||
import { forceKillVitestProcessGroup } from "./vitest-process-group.mjs";
|
||||
|
||||
// Keep this shim so `pnpm test -- src/foo.test.ts` still forwards filters
|
||||
// cleanly instead of leaking pnpm's passthrough sentinel to Vitest.
|
||||
let releaseLock = () => {};
|
||||
let lockReleased = false;
|
||||
|
||||
const releaseLockOnce = () => {
|
||||
if (lockReleased) {
|
||||
return;
|
||||
}
|
||||
lockReleased = true;
|
||||
releaseLock();
|
||||
};
|
||||
|
||||
function isWrapperMetadataRequest(args) {
|
||||
for (const arg of args) {
|
||||
if (arg === "--") {
|
||||
return false;
|
||||
}
|
||||
if (arg === "--help" || arg === "-h") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function printHelp() {
|
||||
console.log(`Usage: node scripts/test-projects.mjs [--changed <base>] [--watch] [targets...] [-- vitest-args...]
|
||||
|
||||
Runs the Vitest project shards that own the requested targets. With no targets,
|
||||
this runs the full local suite. Use explicit targets for local edit loops.`);
|
||||
}
|
||||
|
||||
function cleanupVitestRunSpec(spec) {
|
||||
if (!spec.includeFilePath) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
fs.rmSync(spec.includeFilePath, { force: true });
|
||||
} catch {
|
||||
// Best-effort cleanup for temp include lists.
|
||||
}
|
||||
}
|
||||
|
||||
function runVitestSpec(spec) {
|
||||
if (spec.includeFilePath && spec.includePatterns) {
|
||||
writeVitestIncludeFile(spec.includeFilePath, spec.includePatterns);
|
||||
}
|
||||
let noOutputTimedOut = false;
|
||||
return new Promise((resolve, reject) => {
|
||||
const { child, getForwardedSignal, teardown } = spawnWatchedVitestProcess({
|
||||
pnpmArgs: spec.pnpmArgs,
|
||||
env: spec.env,
|
||||
label: spec.config,
|
||||
onNoOutputTimeout: () => {
|
||||
noOutputTimedOut = true;
|
||||
},
|
||||
spawnParams: {
|
||||
cwd: process.cwd(),
|
||||
...resolveVitestSpawnParams(spec.env),
|
||||
},
|
||||
});
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
teardown();
|
||||
cleanupVitestRunSpec(spec);
|
||||
const forwardedSignal = getForwardedSignal();
|
||||
if (forwardedSignal) {
|
||||
forceKillVitestProcessGroup(child);
|
||||
resolve({ code: 143, noOutputTimedOut, signal: forwardedSignal });
|
||||
return;
|
||||
}
|
||||
resolve({ code: code ?? (signal ? 143 : 1), noOutputTimedOut, signal });
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
teardown();
|
||||
cleanupVitestRunSpec(spec);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function applyDefaultParallelVitestWorkerBudget(specs, env) {
|
||||
if (env.OPENCLAW_VITEST_MAX_WORKERS || env.OPENCLAW_TEST_WORKERS || isCiLikeEnv(env)) {
|
||||
return specs;
|
||||
}
|
||||
const { vitestMaxWorkers } = resolveLocalFullSuiteProfile(env);
|
||||
return specs.map((spec) => ({
|
||||
...spec,
|
||||
env: {
|
||||
...spec.env,
|
||||
OPENCLAW_VITEST_MAX_WORKERS: String(vitestMaxWorkers),
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
async function runLoggedVitestSpec(spec) {
|
||||
console.error(`[test] starting ${spec.config}`);
|
||||
const startedAt = performance.now();
|
||||
let result = await runVitestSpec(spec);
|
||||
if (result.noOutputTimedOut && !spec.watchMode && shouldRetryVitestNoOutputTimeout(spec.env)) {
|
||||
console.error(`[test] retrying ${spec.config} after no-output timeout`);
|
||||
result = await runVitestSpec(spec);
|
||||
}
|
||||
const durationMs = performance.now() - startedAt;
|
||||
if (result.noOutputTimedOut && result.signal) {
|
||||
console.error(`[test] ${spec.config} exceeded no-output timeout`);
|
||||
return {
|
||||
...result,
|
||||
code: result.code || 143,
|
||||
signal: null,
|
||||
timing: null,
|
||||
};
|
||||
}
|
||||
if (result.signal) {
|
||||
console.error(`[test] ${spec.config} exited by signal ${result.signal}`);
|
||||
releaseLockOnce();
|
||||
process.kill(process.pid, result.signal);
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
...result,
|
||||
timing: createShardTimingSample(spec, durationMs),
|
||||
};
|
||||
}
|
||||
|
||||
function isFullExtensionsProjectRun(specs) {
|
||||
const fullExtensionProjectConfigs = new Set(listFullExtensionVitestProjectConfigs());
|
||||
return (
|
||||
specs.length > 1 &&
|
||||
specs.every(
|
||||
(spec) =>
|
||||
spec.watchMode === false &&
|
||||
spec.includePatterns === null &&
|
||||
fullExtensionProjectConfigs.has(spec.config),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function printNoChangedTestTargets(args, cwd, baseEnv) {
|
||||
const plan = resolveChangedTestTargetPlanForArgs(args, cwd, undefined, { env: baseEnv });
|
||||
const skippedBroadFallbackPaths = plan?.skippedBroadFallbackPaths ?? [];
|
||||
for (const line of formatNoChangedTestTargetLines(skippedBroadFallbackPaths)) {
|
||||
console.error(line);
|
||||
}
|
||||
}
|
||||
|
||||
async function runVitestSpecsParallel(specs, concurrency) {
|
||||
let nextIndex = 0;
|
||||
let exitCode = 0;
|
||||
const failures = [];
|
||||
const timings = [];
|
||||
|
||||
const runWorker = async () => {
|
||||
for (;;) {
|
||||
const index = nextIndex;
|
||||
nextIndex += 1;
|
||||
const spec = specs[index];
|
||||
if (!spec) {
|
||||
return;
|
||||
}
|
||||
const result = await runLoggedVitestSpec(spec);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
if (result.code !== 0) {
|
||||
exitCode = exitCode || result.code;
|
||||
failures.push({
|
||||
code: result.code,
|
||||
config: spec.config,
|
||||
includePatterns: spec.includePatterns,
|
||||
noOutputTimedOut: result.noOutputTimedOut,
|
||||
order: index,
|
||||
signal: result.signal,
|
||||
});
|
||||
}
|
||||
if (result.timing) {
|
||||
timings.push(result.timing);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await Promise.all(Array.from({ length: concurrency }, () => runWorker()));
|
||||
return { exitCode, failures, timings };
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const suiteStartedAt = performance.now();
|
||||
const args = process.argv.slice(2);
|
||||
if (isWrapperMetadataRequest(args)) {
|
||||
printHelp();
|
||||
return;
|
||||
}
|
||||
const baseEnv = resolveLocalVitestEnv(process.env);
|
||||
const { targetArgs } = parseTestProjectsArgs(args, process.cwd());
|
||||
const unmatchedExplicitTargets = findUnmatchedExplicitTestTargets(args, process.cwd());
|
||||
if (unmatchedExplicitTargets.length > 0) {
|
||||
for (const unmatched of unmatchedExplicitTargets) {
|
||||
const suffix = unmatched.includePattern ? ` (${unmatched.includePattern})` : "";
|
||||
console.error(
|
||||
`[test] explicit test target matched no test files: ${unmatched.target}${suffix}`,
|
||||
);
|
||||
}
|
||||
printTestSummary("failed", 1, performance.now() - suiteStartedAt);
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
const changedTargetArgs =
|
||||
targetArgs.length === 0
|
||||
? resolveChangedTargetArgs(args, process.cwd(), undefined, { env: baseEnv })
|
||||
: null;
|
||||
const rawRunSpecs =
|
||||
targetArgs.length === 0 && changedTargetArgs === null
|
||||
? buildFullSuiteVitestRunPlans(args, process.cwd()).map((plan) => ({
|
||||
config: plan.config,
|
||||
continueOnFailure: true,
|
||||
env: baseEnv,
|
||||
includeFilePath: null,
|
||||
includePatterns: null,
|
||||
pnpmArgs: [
|
||||
"exec",
|
||||
"node",
|
||||
...resolveVitestNodeArgs(process.env),
|
||||
resolveVitestCliEntry(),
|
||||
...(plan.watchMode ? [] : ["run"]),
|
||||
"--config",
|
||||
plan.config,
|
||||
...plan.forwardedArgs,
|
||||
],
|
||||
watchMode: plan.watchMode,
|
||||
}))
|
||||
: createVitestRunSpecs(args, {
|
||||
baseEnv,
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
const runSpecs = applyDefaultMultiSpecVitestCachePaths(
|
||||
applyDefaultVitestNoOutputTimeout(rawRunSpecs, { env: baseEnv }),
|
||||
{ cwd: process.cwd(), env: baseEnv },
|
||||
);
|
||||
|
||||
if (runSpecs.length === 0) {
|
||||
printNoChangedTestTargets(args, process.cwd(), baseEnv);
|
||||
printTestSummary("skipped", 0, performance.now() - suiteStartedAt);
|
||||
return;
|
||||
}
|
||||
|
||||
releaseLock = shouldAcquireLocalHeavyCheckLock(runSpecs, baseEnv)
|
||||
? acquireLocalHeavyCheckLockSync({
|
||||
cwd: process.cwd(),
|
||||
env: baseEnv,
|
||||
toolName: "test",
|
||||
})
|
||||
: () => {};
|
||||
|
||||
const isFullSuiteRun =
|
||||
targetArgs.length === 0 &&
|
||||
changedTargetArgs === null &&
|
||||
!runSpecs.some((spec) => spec.watchMode);
|
||||
const isExplicitParallelMultiConfigRun =
|
||||
Boolean(baseEnv.OPENCLAW_TEST_PROJECTS_PARALLEL) &&
|
||||
runSpecs.length > 1 &&
|
||||
!runSpecs.some((spec) => spec.watchMode);
|
||||
const isParallelShardRun =
|
||||
isFullSuiteRun || isFullExtensionsProjectRun(runSpecs) || isExplicitParallelMultiConfigRun;
|
||||
if (isParallelShardRun) {
|
||||
const concurrency = resolveParallelFullSuiteConcurrency(runSpecs.length, baseEnv);
|
||||
if (!isCiLikeEnv(baseEnv) && runSpecs.length > 1) {
|
||||
console.warn(
|
||||
`[test] warning: broad local run will start ${runSpecs.length} Vitest shards; use \`pnpm test:changed\` for routine checks.`,
|
||||
);
|
||||
}
|
||||
if (concurrency > 1) {
|
||||
const localFullSuiteProfile = resolveLocalFullSuiteProfile(baseEnv);
|
||||
const shardTimings = readShardTimings(process.cwd(), baseEnv);
|
||||
const parallelSpecs = applyDefaultParallelVitestWorkerBudget(
|
||||
applyParallelVitestCachePaths(orderFullSuiteSpecsForParallelRun(runSpecs, shardTimings), {
|
||||
cwd: process.cwd(),
|
||||
env: baseEnv,
|
||||
}),
|
||||
baseEnv,
|
||||
);
|
||||
if (
|
||||
!isCiLikeEnv(baseEnv) &&
|
||||
!baseEnv.OPENCLAW_TEST_PROJECTS_PARALLEL &&
|
||||
!baseEnv.OPENCLAW_VITEST_MAX_WORKERS &&
|
||||
!baseEnv.OPENCLAW_TEST_WORKERS &&
|
||||
localFullSuiteProfile.shardParallelism === 10 &&
|
||||
localFullSuiteProfile.vitestMaxWorkers === 2
|
||||
) {
|
||||
console.error("[test] using host-aware local full-suite profile: shards=10 workers=2");
|
||||
}
|
||||
console.error(
|
||||
`[test] running ${parallelSpecs.length} Vitest shards with parallelism ${concurrency}`,
|
||||
);
|
||||
const {
|
||||
exitCode: parallelExitCode,
|
||||
failures,
|
||||
timings,
|
||||
} = await runVitestSpecsParallel(parallelSpecs, concurrency);
|
||||
writeShardTimings(timings, process.cwd(), baseEnv);
|
||||
printTestSummary(
|
||||
parallelExitCode === 0 ? "passed" : "failed",
|
||||
parallelSpecs.length,
|
||||
performance.now() - suiteStartedAt,
|
||||
"Vitest summaries above are per-shard, not aggregate totals.",
|
||||
);
|
||||
for (const line of formatFailedShardDigest(failures)) {
|
||||
console.error(line);
|
||||
}
|
||||
releaseLockOnce();
|
||||
if (parallelExitCode !== 0) {
|
||||
process.exit(parallelExitCode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let exitCode = 0;
|
||||
const timings = [];
|
||||
for (const spec of runSpecs) {
|
||||
const result = await runLoggedVitestSpec(spec);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
if (result.timing) {
|
||||
timings.push(result.timing);
|
||||
}
|
||||
if (result.code !== 0) {
|
||||
exitCode = exitCode || result.code;
|
||||
if (spec.continueOnFailure !== true) {
|
||||
printTestSummary("failed", timings.length, performance.now() - suiteStartedAt);
|
||||
releaseLockOnce();
|
||||
process.exit(result.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
writeShardTimings(timings, process.cwd(), baseEnv);
|
||||
printTestSummary(
|
||||
exitCode === 0 ? "passed" : "failed",
|
||||
timings.length,
|
||||
performance.now() - suiteStartedAt,
|
||||
);
|
||||
|
||||
releaseLockOnce();
|
||||
if (exitCode !== 0) {
|
||||
process.exit(exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
function printTestSummary(status, shardCount, durationMs, detail) {
|
||||
const suffix = detail ? `; ${detail}` : "";
|
||||
console.error(
|
||||
`[test] ${status} ${shardCount} Vitest shard${shardCount === 1 ? "" : "s"} in ${formatMs(durationMs)}${suffix}`,
|
||||
);
|
||||
}
|
||||
|
||||
main().catch(
|
||||
/** @param {unknown} error */ (error) => {
|
||||
releaseLockOnce();
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user