fix(ci): stabilize planner executor fallback tests

This commit is contained in:
Vincent Koc 2026-03-31 20:26:13 +09:00
parent 8c0245f57b
commit 225dfe0094
2 changed files with 6 additions and 24 deletions

View File

@ -343,6 +343,7 @@ const partitionUnitsBySurface = (units, surface) => {
export async function executePlan(plan, options = {}) {
const env = options.env ?? process.env;
const artifacts = options.artifacts ?? createExecutionArtifacts(env);
const spawnImpl = options.spawn ?? spawn;
const pnpmInvocation = resolvePnpmCommandInvocation({
npmExecPath: env.npm_execpath,
nodeExecPath: process.execPath,
@ -740,7 +741,7 @@ export async function executePlan(plan, options = {}) {
childEnv.OPENCLAW_VITEST_FS_MODULE_CACHE_PATH = vitestFsModuleCachePath;
laneLogStream.write(`[test-parallel] fsModuleCachePath=${vitestFsModuleCachePath}\n`);
}
child = spawn(pnpmInvocation.command, spawnArgs, {
child = spawnImpl(pnpmInvocation.command, spawnArgs, {
stdio: ["inherit", "pipe", "pipe"],
env: childEnv,
shell: false,

View File

@ -1,7 +1,7 @@
import { EventEmitter } from "node:events";
import { PassThrough } from "node:stream";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { importFreshModule } from "../helpers/import-fresh.js";
import { createExecutionArtifacts, executePlan } from "../../scripts/test-planner/executor.mjs";
beforeEach(() => {
vi.spyOn(console, "log").mockImplementation(() => {});
@ -13,7 +13,6 @@ beforeEach(() => {
afterEach(() => {
vi.useRealTimers();
vi.restoreAllMocks();
vi.resetModules();
});
describe("test planner executor", () => {
@ -33,13 +32,6 @@ describe("test planner executor", () => {
}, 0);
return fakeChild;
});
vi.doMock("node:child_process", () => ({
spawn: spawnMock,
}));
const { executePlan, createExecutionArtifacts } = await importFreshModule<
typeof import("../../scripts/test-planner/executor.mjs")
>(import.meta.url, "../../scripts/test-planner/executor.mjs?scope=exit-fallback");
const artifacts = createExecutionArtifacts({ OPENCLAW_TEST_CLOSE_GRACE_MS: "10" });
const executePromise = executePlan(
{
@ -51,6 +43,7 @@ describe("test planner executor", () => {
{
env: { OPENCLAW_TEST_CLOSE_GRACE_MS: "10" },
artifacts,
spawn: spawnMock,
},
);
@ -93,13 +86,6 @@ describe("test planner executor", () => {
}, 0);
return child;
});
vi.doMock("node:child_process", () => ({
spawn: spawnMock,
}));
const { executePlan, createExecutionArtifacts } = await importFreshModule<
typeof import("../../scripts/test-planner/executor.mjs")
>(import.meta.url, "../../scripts/test-planner/executor.mjs?scope=collect-all");
const artifacts = createExecutionArtifacts({});
const report = await executePlan(
{
@ -125,6 +111,7 @@ describe("test planner executor", () => {
{
env: {},
artifacts,
spawn: spawnMock,
},
);
@ -159,13 +146,6 @@ describe("test planner executor", () => {
}, 0);
return fakeChild;
});
vi.doMock("node:child_process", () => ({
spawn: spawnMock,
}));
const { executePlan, createExecutionArtifacts } = await importFreshModule<
typeof import("../../scripts/test-planner/executor.mjs")
>(import.meta.url, "../../scripts/test-planner/executor.mjs?scope=localstorage-file");
const artifacts = createExecutionArtifacts({
NODE_OPTIONS: "--max_old_space_size=4096 --localstorage-file",
});
@ -193,6 +173,7 @@ describe("test planner executor", () => {
NODE_OPTIONS: "--max_old_space_size=4096 --localstorage-file",
},
artifacts,
spawn: spawnMock,
},
),
).resolves.toMatchObject({