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

View File

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