mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-30 17:14:40 +08:00
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import fs from "fs/promises"
|
|
import path from "path"
|
|
import { tmpdir } from "../../fixture/fixture"
|
|
import { resolveThreadDirectory } from "../../../src/cli/cmd/tui/thread"
|
|
|
|
describe("tui thread", () => {
|
|
async function check(project?: string) {
|
|
await using tmp = await tmpdir({ git: true })
|
|
const link = path.join(path.dirname(tmp.path), path.basename(tmp.path) + "-link")
|
|
const type = process.platform === "win32" ? "junction" : "dir"
|
|
|
|
try {
|
|
await fs.symlink(tmp.path, link, type)
|
|
expect(resolveThreadDirectory(project, link, tmp.path)).toBe(tmp.path)
|
|
} finally {
|
|
await fs.rm(link, { recursive: true, force: true }).catch(() => undefined)
|
|
}
|
|
}
|
|
|
|
test("uses the real cwd when PWD points at a symlink", async () => {
|
|
await check()
|
|
})
|
|
|
|
test("uses the real cwd after resolving a relative project from PWD", async () => {
|
|
await check(".")
|
|
})
|
|
|
|
// kilocode_change start
|
|
test("ignores stale PWD after cwd is changed by a process wrapper", async () => {
|
|
await using root = await tmpdir()
|
|
const pkg = path.join(root.path, "packages", "opencode")
|
|
await fs.mkdir(pkg, { recursive: true })
|
|
|
|
expect(resolveThreadDirectory(".", root.path, pkg)).toBe(pkg)
|
|
})
|
|
// kilocode_change end
|
|
})
|