fix(cli): resolve bundled OpenTUI native modules

This commit is contained in:
marius-kilocode
2026-07-24 15:09:23 +02:00
parent a33493e722
commit f3a4003356
2 changed files with 46 additions and 0 deletions
@@ -1,5 +1,6 @@
import { describe, expect, test } from "bun:test"
import fs from "fs/promises"
import os from "os"
import path from "path"
import { TestCli } from "../../script/kilocode/test-cli"
@@ -52,6 +53,40 @@ describe("CLI subprocess test bundle", () => {
const results = await Promise.all(runs)
expect(results.map(([code]) => code)).toEqual([0, 0, 0, 0])
for (const [, stderr] of results) expect(stderr).toContain("Commands:")
const outside = await fs.mkdtemp(path.join(os.tmpdir(), "kilo-test-cli-cwd-"))
const serve = Bun.spawn([process.execPath, "run", entry, "serve", "--hostname", "127.0.0.1", "--port", "0"], {
cwd: outside,
env: {
...process.env,
KILO_DB: ":memory:",
KILO_CONFIG_CONTENT: "{}",
KILO_AUTH_CONTENT: "{}",
KILO_DISABLE_MODELS_FETCH: "1",
KILO_DISABLE_PROJECT_CONFIG: "1",
KILO_PURE: "1",
},
stdout: "pipe",
stderr: "pipe",
windowsHide: true,
})
const stderr = new Response(serve.stderr).text()
const output = await (async () => {
const reader = serve.stdout.getReader()
const decoder = new TextDecoder()
let text = ""
while (!text.includes("kilo server listening on")) {
const chunk = await reader.read()
if (chunk.done) break
text += decoder.decode(chunk.value, { stream: true })
}
reader.releaseLock()
return text
})()
if (serve.exitCode === null) serve.kill()
const [code, err] = await Promise.all([serve.exited, stderr])
expect(output, `stdout:\n${output}\nstderr:\n${err}`).toContain("kilo server listening on")
expect(code, `stdout:\n${output}\nstderr:\n${err}`).not.toBe(1)
} finally {
if (!process.env[TestCli.ENV]) await fs.rm(dir, { recursive: true, force: true })
}