mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:24:31 +00:00
perf(test): replace claude runner call polling loop
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { sleep } from "../utils.js";
|
|
||||||
import { runClaudeCliAgent } from "./claude-cli-runner.js";
|
import { runClaudeCliAgent } from "./claude-cli-runner.js";
|
||||||
|
|
||||||
const mocks = vi.hoisted(() => ({
|
const mocks = vi.hoisted(() => ({
|
||||||
@@ -65,13 +64,12 @@ function successExit(payload: { message: string; session_id: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function waitForCalls(mockFn: { mock: { calls: unknown[][] } }, count: number) {
|
async function waitForCalls(mockFn: { mock: { calls: unknown[][] } }, count: number) {
|
||||||
for (let i = 0; i < 50; i += 1) {
|
await vi.waitFor(
|
||||||
if (mockFn.mock.calls.length >= count) {
|
() => {
|
||||||
return;
|
expect(mockFn.mock.calls.length).toBeGreaterThanOrEqual(count);
|
||||||
}
|
},
|
||||||
await sleep(0);
|
{ timeout: 2_000, interval: 5 },
|
||||||
}
|
);
|
||||||
throw new Error(`Expected ${count} calls, got ${mockFn.mock.calls.length}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("runClaudeCliAgent", () => {
|
describe("runClaudeCliAgent", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user