Skip to content

Commit 526925c

Browse files
committed
test: stabilize remaining CI flakes
1 parent 3204efc commit 526925c

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/agents/embedded-agent-runner/run/attempt.cwd-split.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import fs from "node:fs/promises";
2+
import os from "node:os";
3+
import path from "node:path";
14
import { afterEach, beforeEach, describe, expect, it } from "vitest";
25
import {
36
cleanupTempPaths,
@@ -22,13 +25,15 @@ describe("runEmbeddedAttempt cwd/workspace split", () => {
2225

2326
it("uses workspace for bootstrap and cwd for runtime tools", async () => {
2427
const bootstrap = createContextEngineBootstrapAndAssemble();
28+
const taskRepo = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-task-repo-"));
29+
tempPaths.push(taskRepo);
2530

2631
await createContextEngineAttemptRunner({
2732
contextEngine: bootstrap,
2833
sessionKey: "agent:main:subagent:child",
2934
tempPaths,
3035
attemptOverrides: {
31-
cwd: "/tmp/task-repo",
36+
cwd: taskRepo,
3237
disableTools: false,
3338
},
3439
});
@@ -42,14 +47,14 @@ describe("runEmbeddedAttempt cwd/workspace split", () => {
4247
const toolsCall = hoisted.createOpenClawCodingToolsMock.mock.calls[0]?.[0] as
4348
| { cwd?: string; workspaceDir?: string; spawnWorkspaceDir?: string }
4449
| undefined;
45-
expect(toolsCall?.cwd).toBe("/tmp/task-repo");
50+
expect(toolsCall?.cwd).toBe(taskRepo);
4651
expect(toolsCall?.workspaceDir).toBe(bootstrapCall?.workspaceDir);
4752
expect(toolsCall?.spawnWorkspaceDir).toBe(bootstrapCall?.workspaceDir);
4853

4954
const resourceLoaderInit = hoisted.defaultResourceLoaderInitMock.mock.calls[0]?.[0] as
5055
| { cwd?: string }
5156
| undefined;
52-
expect(resourceLoaderInit?.cwd).toBe("/tmp/task-repo");
57+
expect(resourceLoaderInit?.cwd).toBe(taskRepo);
5358
});
5459

5560
it("rejects cwd overrides for sandboxed runs instead of silently ignoring them", async () => {

src/gateway/gateway-cli-backend.live-helpers.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ vi.mock("./client.js", () => ({
2323
},
2424
}));
2525

26+
vi.mock("./client-start-readiness.js", () => ({
27+
startGatewayClientWhenEventLoopReady: async (client: { start: () => void }) => {
28+
client.start();
29+
return { ready: true, aborted: false, elapsedMs: 0, maxDriftMs: 0, checks: 0 };
30+
},
31+
}));
32+
2633
describe("gateway cli backend live helpers", () => {
2734
let liveHelpers: typeof import("./gateway-cli-backend.live-helpers.js");
2835

src/infra/exec-wrapper-trust-plan.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ describe("resolveExecWrapperTrustPlan", () => {
3030
},
3131
},
3232
{
33-
name: "unwraps script wrappers before evaluating nested shell payloads",
33+
name: "blocks script wrappers before evaluating nested shell payloads",
3434
enabled: process.platform === "darwin" || process.platform === "freebsd",
3535
argv: ["/usr/bin/script", "-q", "/dev/null", "sh", "-c", "echo hi"],
3636
expected: {
37-
argv: ["sh", "-c", "echo hi"],
38-
policyArgv: ["sh", "-c", "echo hi"],
39-
wrapperChain: ["script"],
40-
policyBlocked: false,
41-
shellWrapperExecutable: true,
42-
shellInlineCommand: "echo hi",
37+
argv: ["/usr/bin/script", "-q", "/dev/null", "sh", "-c", "echo hi"],
38+
policyArgv: ["/usr/bin/script", "-q", "/dev/null", "sh", "-c", "echo hi"],
39+
wrapperChain: [],
40+
policyBlocked: true,
41+
blockedWrapper: "script",
42+
shellWrapperExecutable: false,
43+
shellInlineCommand: null,
4344
},
4445
},
4546
{

0 commit comments

Comments
 (0)