fix(test): replace Unix-only assumptions with cross-platform alternatives (#14906)

This commit is contained in:
Luke Parker
2026-02-24 23:03:18 +10:00
committed by GitHub
parent 06f25c78f6
commit 3d379c20c4
3 changed files with 19 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
import { describe, expect, test } from "bun:test"
import os from "os"
import path from "path"
import { BashTool } from "../../src/tool/bash"
import { Instance } from "../../src/project/instance"
@@ -138,14 +139,14 @@ describe("tool.bash permissions", () => {
await bash.execute(
{
command: "ls",
workdir: "/tmp",
description: "List /tmp",
workdir: os.tmpdir(),
description: "List temp dir",
},
testCtx,
)
const extDirReq = requests.find((r) => r.permission === "external_directory")
expect(extDirReq).toBeDefined()
expect(extDirReq!.patterns).toContain("/tmp/*")
expect(extDirReq!.patterns).toContain(path.join(os.tmpdir(), "*"))
},
})
})
@@ -366,7 +367,8 @@ describe("tool.bash truncation", () => {
ctx,
)
expect((result.metadata as any).truncated).toBe(false)
expect(result.output).toBe("hello\n")
const eol = process.platform === "win32" ? "\r\n" : "\n"
expect(result.output).toBe(`hello${eol}`)
},
})
})