mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-01 18:48:16 +00:00
perf(test): trim bash e2e sleep and poll windows
This commit is contained in:
@@ -12,9 +12,10 @@ const defaultShell = isWin
|
|||||||
? undefined
|
? undefined
|
||||||
: process.env.OPENCLAW_TEST_SHELL || resolveShellFromPath("bash") || process.env.SHELL || "sh";
|
: process.env.OPENCLAW_TEST_SHELL || resolveShellFromPath("bash") || process.env.SHELL || "sh";
|
||||||
// PowerShell: Start-Sleep for delays, ; for command separation, $null for null device
|
// PowerShell: Start-Sleep for delays, ; for command separation, $null for null device
|
||||||
const shortDelayCmd = isWin ? "Start-Sleep -Milliseconds 50" : "sleep 0.05";
|
const shortDelayCmd = isWin ? "Start-Sleep -Milliseconds 30" : "sleep 0.03";
|
||||||
const yieldDelayCmd = isWin ? "Start-Sleep -Milliseconds 200" : "sleep 0.2";
|
const yieldDelayCmd = isWin ? "Start-Sleep -Milliseconds 120" : "sleep 0.12";
|
||||||
const longDelayCmd = isWin ? "Start-Sleep -Seconds 2" : "sleep 2";
|
const longDelayCmd = isWin ? "Start-Sleep -Seconds 1" : "sleep 1";
|
||||||
|
const POLL_INTERVAL_MS = 15;
|
||||||
// Both PowerShell and bash use ; for command separation
|
// Both PowerShell and bash use ; for command separation
|
||||||
const joinCommands = (commands: string[]) => commands.join("; ");
|
const joinCommands = (commands: string[]) => commands.join("; ");
|
||||||
const echoAfterDelay = (message: string) => joinCommands([shortDelayCmd, `echo ${message}`]);
|
const echoAfterDelay = (message: string) => joinCommands([shortDelayCmd, `echo ${message}`]);
|
||||||
@@ -40,7 +41,7 @@ async function waitForCompletion(sessionId: string) {
|
|||||||
status = (poll.details as { status: string }).status;
|
status = (poll.details as { status: string }).status;
|
||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
{ timeout: process.platform === "win32" ? 8000 : 2000, interval: 20 },
|
{ timeout: process.platform === "win32" ? 8000 : 1500, interval: POLL_INTERVAL_MS },
|
||||||
)
|
)
|
||||||
.not.toBe("running");
|
.not.toBe("running");
|
||||||
return status;
|
return status;
|
||||||
@@ -99,7 +100,7 @@ describe("exec tool backgrounding", () => {
|
|||||||
output = textBlock?.text ?? "";
|
output = textBlock?.text ?? "";
|
||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
{ timeout: process.platform === "win32" ? 8000 : 2000, interval: 20 },
|
{ timeout: process.platform === "win32" ? 8000 : 1500, interval: POLL_INTERVAL_MS },
|
||||||
)
|
)
|
||||||
.toBe("completed");
|
.toBe("completed");
|
||||||
|
|
||||||
@@ -137,13 +138,13 @@ describe("exec tool backgrounding", () => {
|
|||||||
).sessions;
|
).sessions;
|
||||||
return sessions.find((s) => s.sessionId === sessionId)?.name;
|
return sessions.find((s) => s.sessionId === sessionId)?.name;
|
||||||
},
|
},
|
||||||
{ timeout: process.platform === "win32" ? 8000 : 2000, interval: 20 },
|
{ timeout: process.platform === "win32" ? 8000 : 1500, interval: POLL_INTERVAL_MS },
|
||||||
)
|
)
|
||||||
.toBe("echo hello");
|
.toBe("echo hello");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses default timeout when timeout is omitted", async () => {
|
it("uses default timeout when timeout is omitted", async () => {
|
||||||
const customBash = createExecTool({ timeoutSec: 0.2, backgroundMs: 10 });
|
const customBash = createExecTool({ timeoutSec: 0.12, backgroundMs: 10 });
|
||||||
const customProcess = createProcessTool();
|
const customProcess = createProcessTool();
|
||||||
|
|
||||||
const result = await customBash.execute("call1", {
|
const result = await customBash.execute("call1", {
|
||||||
@@ -161,7 +162,7 @@ describe("exec tool backgrounding", () => {
|
|||||||
});
|
});
|
||||||
return (poll.details as { status: string }).status;
|
return (poll.details as { status: string }).status;
|
||||||
},
|
},
|
||||||
{ timeout: 5000, interval: 20 },
|
{ timeout: 5000, interval: POLL_INTERVAL_MS },
|
||||||
)
|
)
|
||||||
.toBe("failed");
|
.toBe("failed");
|
||||||
});
|
});
|
||||||
@@ -356,7 +357,7 @@ describe("exec notifyOnExit", () => {
|
|||||||
hasEvent = peekSystemEvents("agent:main:main").some((event) => event.includes(prefix));
|
hasEvent = peekSystemEvents("agent:main:main").some((event) => event.includes(prefix));
|
||||||
return Boolean(finished && hasEvent);
|
return Boolean(finished && hasEvent);
|
||||||
},
|
},
|
||||||
{ timeout: isWin ? 12_000 : 5_000, interval: 20 },
|
{ timeout: isWin ? 12_000 : 5_000, interval: POLL_INTERVAL_MS },
|
||||||
)
|
)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
if (!finished) {
|
if (!finished) {
|
||||||
|
|||||||
Reference in New Issue
Block a user