mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 15:41:23 +00:00
perf(test): cut slow monitor/subagent test overhead
This commit is contained in:
@@ -47,13 +47,20 @@ test("exec disposes PTY listeners after normal exit", async () => {
|
||||
test("exec tears down PTY resources on timeout", async () => {
|
||||
const disposeData = vi.fn();
|
||||
const disposeExit = vi.fn();
|
||||
const kill = vi.fn();
|
||||
let exitListener: ((event: { exitCode: number; signal?: number }) => void) | undefined;
|
||||
const kill = vi.fn(() => {
|
||||
// Mirror real PTY behavior: process exits shortly after force-kill.
|
||||
exitListener?.({ exitCode: 137, signal: 9 });
|
||||
});
|
||||
|
||||
ptySpawnMock.mockImplementation(() => ({
|
||||
pid: 0,
|
||||
write: vi.fn(),
|
||||
onData: () => ({ dispose: disposeData }),
|
||||
onExit: () => ({ dispose: disposeExit }),
|
||||
onExit: (listener: (event: { exitCode: number; signal?: number }) => void) => {
|
||||
exitListener = listener;
|
||||
return { dispose: disposeExit };
|
||||
},
|
||||
kill,
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
callGatewayMock,
|
||||
setSubagentsConfigOverride,
|
||||
} from "./openclaw-tools.subagents.test-harness.js";
|
||||
import {
|
||||
addSubagentRunForTests,
|
||||
listSubagentRunsForRequester,
|
||||
resetSubagentRegistryForTests,
|
||||
} from "./subagent-registry.js";
|
||||
import "./test-helpers/fast-core-tools.js";
|
||||
|
||||
let createOpenClawTools: (typeof import("./openclaw-tools.js"))["createOpenClawTools"];
|
||||
let addSubagentRunForTests: (typeof import("./subagent-registry.js"))["addSubagentRunForTests"];
|
||||
let listSubagentRunsForRequester: (typeof import("./subagent-registry.js"))["listSubagentRunsForRequester"];
|
||||
let resetSubagentRegistryForTests: (typeof import("./subagent-registry.js"))["resetSubagentRegistryForTests"];
|
||||
import { createSubagentsTool } from "./tools/subagents-tool.js";
|
||||
|
||||
describe("openclaw-tools: subagents steer failure", () => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ createOpenClawTools } = await import("./openclaw-tools.js"));
|
||||
({ addSubagentRunForTests, listSubagentRunsForRequester, resetSubagentRegistryForTests } =
|
||||
await import("./subagent-registry.js"));
|
||||
beforeEach(() => {
|
||||
resetSubagentRegistryForTests();
|
||||
callGatewayMock.mockReset();
|
||||
const storePath = path.join(
|
||||
@@ -58,13 +55,9 @@ describe("openclaw-tools: subagents steer failure", () => {
|
||||
return {};
|
||||
});
|
||||
|
||||
const tool = createOpenClawTools({
|
||||
const tool = createSubagentsTool({
|
||||
agentSessionKey: "agent:main:main",
|
||||
agentChannel: "discord",
|
||||
}).find((candidate) => candidate.name === "subagents");
|
||||
if (!tool) {
|
||||
throw new Error("missing subagents tool");
|
||||
}
|
||||
});
|
||||
|
||||
const result = await tool.execute("call-steer", {
|
||||
action: "steer",
|
||||
|
||||
Reference in New Issue
Block a user