perf(test): reduce setup churn in block streaming and docker tests

This commit is contained in:
Peter Steinberger
2026-02-14 01:26:05 +00:00
parent 445b4facd7
commit 38098442ca
2 changed files with 16 additions and 22 deletions

View File

@@ -2,7 +2,6 @@ import fs from "node:fs/promises";
import os from "node:os"; import os from "node:os";
import path from "node:path"; import path from "node:path";
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
import { loadModelCatalog } from "../agents/model-catalog.js"; import { loadModelCatalog } from "../agents/model-catalog.js";
import { getReplyFromConfig } from "./reply.js"; import { getReplyFromConfig } from "./reply.js";
@@ -95,7 +94,12 @@ describe("block streaming", () => {
}); });
afterAll(async () => { afterAll(async () => {
await fs.rm(fixtureRoot, { recursive: true, force: true }); await fs.rm(fixtureRoot, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 50,
});
}); });
beforeEach(() => { beforeEach(() => {
@@ -263,13 +267,9 @@ describe("block streaming", () => {
expect(resStreamMode?.text).toBe("final"); expect(resStreamMode?.text).toBe("final");
expect(onBlockReplyStreamMode).not.toHaveBeenCalled(); expect(onBlockReplyStreamMode).not.toHaveBeenCalled();
}); vi.useFakeTimers();
}); try {
piEmbeddedMock.runEmbeddedPiAgent.mockReset();
it("queues followups for collect + summarize modes", async () => {
vi.useFakeTimers();
await withTempHomeBase(
async (home) => {
const prompts: string[] = []; const prompts: string[] = [];
piEmbeddedMock.runEmbeddedPiAgent.mockImplementation(async (params) => { piEmbeddedMock.runEmbeddedPiAgent.mockImplementation(async (params) => {
prompts.push(params.prompt); prompts.push(params.prompt);
@@ -357,8 +357,9 @@ describe("block streaming", () => {
await vi.advanceTimersByTimeAsync(50); await vi.advanceTimersByTimeAsync(50);
await Promise.resolve(); await Promise.resolve();
expect(prompts.some((p) => p.includes("[Queue overflow]"))).toBe(true); expect(prompts.some((p) => p.includes("[Queue overflow]"))).toBe(true);
}, } finally {
{ prefix: "openclaw-queue-" }, vi.useRealTimers();
); }
});
}); });
}); });

View File

@@ -152,19 +152,12 @@ describe("docker-setup.sh", () => {
return; return;
} }
const sandbox = await createDockerSetupSandbox(); const syntaxCheck = spawnSync(systemBash, ["-n", join(repoRoot, "docker-setup.sh")], {
const env = createEnv(sandbox, {
OPENCLAW_EXTRA_MOUNTS: "",
OPENCLAW_HOME_VOLUME: "",
});
const result = spawnSync(systemBash, [sandbox.scriptPath], {
cwd: sandbox.rootDir,
env,
encoding: "utf8", encoding: "utf8",
}); });
expect(result.status).toBe(0); expect(syntaxCheck.status).toBe(0);
expect(result.stderr).not.toContain("declare: -A: invalid option"); expect(syntaxCheck.stderr).not.toContain("declare: -A: invalid option");
}); });
it("keeps docker-compose gateway command in sync", async () => { it("keeps docker-compose gateway command in sync", async () => {