mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:20:44 +00:00
test: stabilize full-suite flakes
This commit is contained in:
@@ -145,9 +145,9 @@ export async function runChangedCheck(result, options = {}) {
|
||||
}
|
||||
} else if (plan.runChangedTestsBroad) {
|
||||
const testArgs = options.explicitPaths
|
||||
? ["scripts/test-projects.mjs"]
|
||||
: ["scripts/test-projects.mjs", "--changed", options.base ?? "origin/main"];
|
||||
const status = await runNode(
|
||||
? ["test"]
|
||||
: ["test", "--changed", options.base ?? "origin/main"];
|
||||
const status = await runPnpm(
|
||||
{
|
||||
name: options.explicitPaths ? "tests all" : "tests changed broad",
|
||||
args: testArgs,
|
||||
@@ -159,10 +159,10 @@ export async function runChangedCheck(result, options = {}) {
|
||||
return status;
|
||||
}
|
||||
} else if (plan.testTargets.length > 0) {
|
||||
const status = await runNode(
|
||||
const status = await runPnpm(
|
||||
{
|
||||
name: "tests changed",
|
||||
args: ["scripts/test-projects.mjs", ...plan.testTargets],
|
||||
args: ["test", ...plan.testTargets],
|
||||
},
|
||||
timings,
|
||||
);
|
||||
@@ -209,10 +209,6 @@ async function runPnpm(command, timings) {
|
||||
return await runCommand({ ...command, bin: "pnpm" }, timings);
|
||||
}
|
||||
|
||||
async function runNode(command, timings) {
|
||||
return await runCommand({ ...command, bin: process.execPath }, timings);
|
||||
}
|
||||
|
||||
async function runCommand(command, timings) {
|
||||
const startedAt = performance.now();
|
||||
console.error(`\n[check:changed] ${command.name}`);
|
||||
|
||||
@@ -180,7 +180,13 @@ export function forwardVitestOutput(stream, target, shouldSuppressLine = () => f
|
||||
});
|
||||
}
|
||||
|
||||
export function spawnWatchedVitestProcess({ pnpmArgs, spawnParams, env, label }) {
|
||||
export function spawnWatchedVitestProcess({
|
||||
pnpmArgs,
|
||||
spawnParams,
|
||||
env,
|
||||
label,
|
||||
onNoOutputTimeout,
|
||||
}) {
|
||||
const child = spawnVitestProcess({
|
||||
pnpmArgs,
|
||||
spawnParams,
|
||||
@@ -194,6 +200,7 @@ export function spawnWatchedVitestProcess({ pnpmArgs, spawnParams, env, label })
|
||||
console.error(message);
|
||||
},
|
||||
onTimeout: () => {
|
||||
onNoOutputTimeout?.();
|
||||
forwardSignalToVitestProcessGroup({
|
||||
child,
|
||||
signal: "SIGTERM",
|
||||
|
||||
@@ -189,11 +189,15 @@ function runVitestSpec(spec) {
|
||||
if (spec.includeFilePath && spec.includePatterns) {
|
||||
writeVitestIncludeFile(spec.includeFilePath, spec.includePatterns);
|
||||
}
|
||||
let noOutputTimedOut = false;
|
||||
return new Promise((resolve, reject) => {
|
||||
const { child, teardown } = spawnWatchedVitestProcess({
|
||||
pnpmArgs: spec.pnpmArgs,
|
||||
env: spec.env,
|
||||
label: spec.config,
|
||||
onNoOutputTimeout: () => {
|
||||
noOutputTimedOut = true;
|
||||
},
|
||||
spawnParams: {
|
||||
cwd: process.cwd(),
|
||||
...resolveVitestSpawnParams(spec.env),
|
||||
@@ -203,7 +207,7 @@ function runVitestSpec(spec) {
|
||||
child.on("exit", (code, signal) => {
|
||||
teardown();
|
||||
cleanupVitestRunSpec(spec);
|
||||
resolve({ code: code ?? 1, signal });
|
||||
resolve({ code: code ?? (signal ? 143 : 1), noOutputTimedOut, signal });
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
@@ -231,8 +235,21 @@ function applyDefaultParallelVitestWorkerBudget(specs, env) {
|
||||
async function runLoggedVitestSpec(spec) {
|
||||
console.error(`[test] starting ${spec.config}`);
|
||||
const startedAt = performance.now();
|
||||
const result = await runVitestSpec(spec);
|
||||
let result = await runVitestSpec(spec);
|
||||
if (result.noOutputTimedOut && !spec.watchMode) {
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user