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