Skip to content

Commit 9ed18c1

Browse files
Gustav-SimonssonTheGreatAxios
authored andcommitted
perf(tests): replace fixed highlight waits with ink polls and trim remaining sleeps
1 parent 25039cb commit 9ed18c1

16 files changed

Lines changed: 480 additions & 400 deletions

‎scripts/ci-timings.json‎

Lines changed: 296 additions & 296 deletions
Large diffs are not rendered by default.

‎scripts/test-parallel.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe("runWithWatchdog", () => {
104104
command: process.execPath,
105105
args: [
106106
"-e",
107-
'process.on("SIGTERM", () => {}); setTimeout(() => process.exit(3), 600);',
107+
'process.on("SIGTERM", () => {}); setTimeout(() => process.exit(3), 400);',
108108
],
109109
stallMs: SILENT_CHILD_STALL_MS,
110110
onStall: () => {

‎src/plugins/shell-guard-plugin.test.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("runGuardedShell", () => {
5757
const feed = createShellOutputFeed();
5858
let finished = false;
5959
const running = runGuardedShell(
60-
{ command: "echo first; sleep 0.02; echo second; sleep 0.4" },
60+
{ command: "echo first; sleep 0.02; echo second; sleep 0.2" },
6161
neverAbort(),
6262
undefined,
6363
undefined,
@@ -85,7 +85,7 @@ describe("runGuardedShell", () => {
8585
test("omitted timeout does not arm a timer", async () => {
8686
const start = Date.now();
8787
const { exitCode, timedOut, output } = await runGuardedShell(
88-
{ command: "sleep 0.25; echo done" },
88+
{ command: "sleep 0.1; echo done" },
8989
neverAbort(),
9090
);
9191
expect(timedOut).toBe(false);
@@ -118,7 +118,7 @@ describe("runGuardedShell", () => {
118118
test("returns partial output and a timed-out flag instead of throwing", async () => {
119119
const start = Date.now();
120120
const { exitCode, timedOut, output } = await runGuardedShell(
121-
{ command: "echo early; sleep 60", timeout: 200 },
121+
{ command: "echo early; sleep 60", timeout: 100 },
122122
neverAbort(),
123123
);
124124
expect(timedOut).toBe(true);
@@ -350,7 +350,7 @@ describe("background run_shell (shellGuardPlugin)", () => {
350350
const result = await runWith(registry, {
351351
id: "bg1",
352352
name: "run_shell",
353-
arguments: { command: "sleep 0.2; echo finished", background: true },
353+
arguments: { command: "sleep 0.05; echo finished", background: true },
354354
});
355355
expect(result.isError).toBeUndefined();
356356
const parsed = JSON.parse(String(result.content)) as {
@@ -656,11 +656,11 @@ describe("shellGuardPlugin", () => {
656656
const result = await run({
657657
id: "c2",
658658
name: "run_shell",
659-
arguments: { command: "echo before; sleep 60", timeout: 120 },
659+
arguments: { command: "echo before; sleep 60", timeout: 80 },
660660
});
661661
expect(result.isError).toBeUndefined();
662662
expect(result.content).toContain("before");
663-
expect(result.content).toMatch(/timed out after 120ms and was terminated/);
663+
expect(result.content).toMatch(/timed out after 80ms and was terminated/);
664664
expect(result.content).toContain("background:true");
665665
});
666666

@@ -684,13 +684,13 @@ describe("shellGuardPlugin", () => {
684684

685685
test("applies a configured default timeout when none is passed", async () => {
686686
const handler = defined(
687-
shellGuardPlugin(process.cwd(), { defaultMs: 90 }).middleware,
687+
shellGuardPlugin(process.cwd(), { defaultMs: 60 }).middleware,
688688
)(fallback);
689689
const result = await handler(
690690
{ id: "c2c", name: "run_shell", arguments: { command: "sleep 60" } },
691691
neverAbort(),
692692
);
693-
expect(result.content).toMatch(/timed out after 90ms/);
693+
expect(result.content).toMatch(/timed out after 60ms/);
694694
});
695695

696696
test("omitted timeout with no settings default still completes a short command", async () => {
@@ -701,7 +701,7 @@ describe("shellGuardPlugin", () => {
701701
{
702702
id: "c2d",
703703
name: "run_shell",
704-
arguments: { command: "sleep 0.2; echo ok" },
704+
arguments: { command: "sleep 0.05; echo ok" },
705705
},
706706
neverAbort(),
707707
);
@@ -1044,7 +1044,7 @@ describe("shellGuardPlugin", () => {
10441044

10451045
test("treats timeout 0 as the configured default", async () => {
10461046
const handler = defined(
1047-
shellGuardPlugin(process.cwd(), { defaultMs: 90, maxMs: 100 }).middleware,
1047+
shellGuardPlugin(process.cwd(), { defaultMs: 60, maxMs: 70 }).middleware,
10481048
)(fallback);
10491049
const result = await handler(
10501050
{
@@ -1054,7 +1054,7 @@ describe("shellGuardPlugin", () => {
10541054
},
10551055
neverAbort(),
10561056
);
1057-
expect(result.content).toMatch(/timed out after 90ms/);
1057+
expect(result.content).toMatch(/timed out after 60ms/);
10581058
});
10591059

10601060
test("returns promptly when the search tool ignores the budget", async () => {

‎src/session/hooks.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe("lifecycle hook payload delivery", () => {
103103
process.on("unhandledRejection", onUnhandled);
104104
try {
105105
await manager.dispatchPostRun(summary);
106-
await new Promise((resolve) => setTimeout(resolve, 100));
106+
await new Promise((resolve) => setTimeout(resolve, 40));
107107
} finally {
108108
process.off("unhandledRejection", onUnhandled);
109109
}

0 commit comments

Comments
 (0)