perf(cli): cut test suite from 32s to 11s wall
Two heavy CLI tests were dominating wall time: - chat.test.ts "--once exits with timeout note" waited the real 30s reply-timeout floor. Added a replyTimeoutMs option to runChatInteractive so the test can use 200ms. - bundled-plugin-install.test.ts "loads the real bundled dependency graph plugin" runs esbuild and a live PluginLoader (~18s). Gated behind FUSION_RUN_SLOW_TESTS=1; the install/upgrade logic is covered by mocked unit tests in the same file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
5
.changeset/cli-tests-faster.md
Normal file
5
.changeset/cli-tests-faster.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@runfusion/fusion": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Make CLI test suite ~3× faster: add a `replyTimeoutMs` option to `runChatInteractive` so the `--once` timeout test no longer waits a real 30s for "No reply within 30s", and gate the heavyweight esbuild-bundled-plugin integration test behind `FUSION_RUN_SLOW_TESTS=1` (the same install/upgrade logic is covered by mocked unit tests in the same file).
|
||||||
@@ -227,12 +227,13 @@ describe("runChatInteractive", () => {
|
|||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
input,
|
input,
|
||||||
output: new PassThrough(),
|
output: new PassThrough(),
|
||||||
pollIntervalMs: 1000,
|
pollIntervalMs: 10,
|
||||||
|
replyTimeoutMs: 200,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(code).toBe(0);
|
expect(code).toBe(0);
|
||||||
expect(errorSpy).toHaveBeenCalledWith("No reply within 30s");
|
expect(errorSpy).toHaveBeenCalledWith("No reply within 1s");
|
||||||
}, 40_000);
|
});
|
||||||
|
|
||||||
it("refuses oversized messages", async () => {
|
it("refuses oversized messages", async () => {
|
||||||
const oversized = "x".repeat(8193);
|
const oversized = "x".repeat(8193);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const HISTORY_LIMIT = 20;
|
|||||||
export interface ChatInteractiveOptions {
|
export interface ChatInteractiveOptions {
|
||||||
project?: string;
|
project?: string;
|
||||||
pollIntervalMs?: number;
|
pollIntervalMs?: number;
|
||||||
|
replyTimeoutMs?: number;
|
||||||
once?: boolean;
|
once?: boolean;
|
||||||
nonInteractive?: boolean;
|
nonInteractive?: boolean;
|
||||||
input?: NodeJS.ReadableStream;
|
input?: NodeJS.ReadableStream;
|
||||||
@@ -151,7 +152,7 @@ export async function runChatInteractive(agentId: string, options: ChatInteracti
|
|||||||
});
|
});
|
||||||
|
|
||||||
output.write(`you → ${agentId}: ${content}\n`);
|
output.write(`you → ${agentId}: ${content}\n`);
|
||||||
const timeoutMs = Math.max(pollIntervalMs * 10, 30_000);
|
const timeoutMs = options.replyTimeoutMs ?? Math.max(pollIntervalMs * 10, 30_000);
|
||||||
const replied = await waitForReply(messageStore, agentId, printedIds, output, pollIntervalMs, timeoutMs);
|
const replied = await waitForReply(messageStore, agentId, printedIds, output, pollIntervalMs, timeoutMs);
|
||||||
if (!replied) {
|
if (!replied) {
|
||||||
console.error(`No reply within ${Math.ceil(timeoutMs / 1000)}s`);
|
console.error(`No reply within ${Math.ceil(timeoutMs / 1000)}s`);
|
||||||
|
|||||||
@@ -534,7 +534,11 @@ describe("ensureBundledDependencyGraphPluginInstalled", () => {
|
|||||||
expect(registerCall.path).toContain(`${HERMES_PLUGIN_ID}/bundled.js`);
|
expect(registerCall.path).toContain(`${HERMES_PLUGIN_ID}/bundled.js`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("loads the real bundled dependency graph plugin and persists a started state", async () => {
|
// Heavy integration test: runs esbuild to bundle the real dependency-graph
|
||||||
|
// plugin and load it through a live PluginLoader. ~18s wall on a fast laptop.
|
||||||
|
// The other tests in this file cover the install/upgrade logic with mocks;
|
||||||
|
// this one is gated behind FUSION_RUN_SLOW_TESTS=1 so day-to-day runs stay fast.
|
||||||
|
it.skipIf(process.env.FUSION_RUN_SLOW_TESTS !== "1")("loads the real bundled dependency graph plugin and persists a started state", async () => {
|
||||||
const { existsSync, mkdtempSync, statSync } = await vi.importActual<typeof import("node:fs")>("node:fs");
|
const { existsSync, mkdtempSync, statSync } = await vi.importActual<typeof import("node:fs")>("node:fs");
|
||||||
const { cp, mkdir, readFile, rm, stat, copyFile } = await vi.importActual<typeof import("node:fs/promises")>("node:fs/promises");
|
const { cp, mkdir, readFile, rm, stat, copyFile } = await vi.importActual<typeof import("node:fs/promises")>("node:fs/promises");
|
||||||
const { tmpdir } = await import("node:os");
|
const { tmpdir } = await import("node:os");
|
||||||
|
|||||||
Reference in New Issue
Block a user