mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:10:58 +00:00
test: simplify changed test routing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
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,
|
||||
@@ -271,6 +272,7 @@ async function runVitestSpecsParallel(specs, concurrency) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const suiteStartedAt = performance.now();
|
||||
const args = process.argv.slice(2);
|
||||
const baseEnv = resolveLocalVitestEnv(process.env);
|
||||
const { targetArgs } = parseTestProjectsArgs(args, process.cwd());
|
||||
@@ -309,6 +311,7 @@ async function main() {
|
||||
|
||||
if (runSpecs.length === 0) {
|
||||
console.error("[test] no changed test targets; skipping Vitest.");
|
||||
printTestSummary("skipped", 0, performance.now() - suiteStartedAt);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,8 +363,11 @@ async function main() {
|
||||
concurrency,
|
||||
);
|
||||
writeShardTimings(timings, process.cwd(), baseEnv);
|
||||
console.error(
|
||||
`[test] completed ${parallelSpecs.length} Vitest shards; Vitest summaries above are per-shard, not aggregate totals.`,
|
||||
printTestSummary(
|
||||
parallelExitCode === 0 ? "passed" : "failed",
|
||||
parallelSpecs.length,
|
||||
performance.now() - suiteStartedAt,
|
||||
"Vitest summaries above are per-shard, not aggregate totals.",
|
||||
);
|
||||
releaseLockOnce();
|
||||
if (parallelExitCode !== 0) {
|
||||
@@ -378,18 +384,24 @@ async function main() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (result.timing) {
|
||||
timings.push(result.timing);
|
||||
}
|
||||
}
|
||||
writeShardTimings(timings, process.cwd(), baseEnv);
|
||||
printTestSummary(
|
||||
exitCode === 0 ? "passed" : "failed",
|
||||
timings.length,
|
||||
performance.now() - suiteStartedAt,
|
||||
);
|
||||
|
||||
releaseLockOnce();
|
||||
if (exitCode !== 0) {
|
||||
@@ -397,6 +409,13 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
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((error) => {
|
||||
releaseLockOnce();
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user