mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
- process.test: every AppProcess test spawns a real child, so run them with it.live. Under TestClock the spawner's 1s post-exit capture deadline never fired, and a late close event hung until the timeout. - browser-idle: give LocationActivity its own clock and advance it by the TTL only after the first browser state attached, instead of racing a real 2s TTL against slow plugin activation. - config/reload: wait for the skills change too before asserting it. - Raise the four file-level 15s defaults to the runner's 30s default; they had become the strictest timeouts in the suite. - The runner passes --timeout=30000 like cli and tui; npm.test's Git installs ran past Bun's 5s default on Windows. - Git fixtures write repo-local settings in one config write instead of a git config spawn per setting. Git for Windows spawns cost about 40ms each, and core spawned about 2,850 per run.
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import fs from "fs/promises"
|
|
import path from "path"
|
|
import { tmpdir } from "../test/fixture/tmpdir"
|
|
|
|
await using directory = await tmpdir("oc-")
|
|
const home = directory.path
|
|
const temporary = path.join(home, "tmp")
|
|
await fs.mkdir(temporary)
|
|
|
|
const environment = {
|
|
...Object.fromEntries(
|
|
Object.entries(process.env).filter(([name]) => {
|
|
if (process.env.RECORD === "true" && name === "OPENAI_API_KEY") return true
|
|
if (
|
|
/^(?:AWS|AZURE|GOOGLE|GCP|GCLOUD|VERTEX|OPENAI|ANTHROPIC|GEMINI|XAI|CLOUDFLARE|CF_AIG|SNOWFLAKE|AICORE|GITLAB|NPM_CONFIG)_/i.test(
|
|
name,
|
|
)
|
|
) {
|
|
return false
|
|
}
|
|
return !/(?:^|_)(?:API_KEY|AUTHORIZATION|TOKEN|SECRET|PASSWORD|CREDENTIALS?)$/i.test(name)
|
|
}),
|
|
),
|
|
HOME: home,
|
|
OPENCODE_TEST_HOME: home,
|
|
XDG_CONFIG_HOME: path.join(home, ".config"),
|
|
XDG_DATA_HOME: path.join(home, ".local", "share"),
|
|
XDG_CACHE_HOME: path.join(home, ".cache"),
|
|
XDG_STATE_HOME: path.join(home, ".local", "state"),
|
|
OPENCODE_CONFIG_DIR: path.join(home, ".config", "opencode"),
|
|
OPENCODE_CONFIG: undefined,
|
|
OPENCODE_CONFIG_CONTENT: undefined,
|
|
TMPDIR: temporary,
|
|
...(process.platform === "win32" ? { USERPROFILE: home, TMP: temporary, TEMP: temporary } : {}),
|
|
}
|
|
|
|
const child = Bun.spawn({
|
|
// The 30s default timeout matches cli and tui; npm.test's Git package installs ran past Bun's 5s default on Windows.
|
|
cmd: [process.execPath, "test", "--only-failures", "--timeout=30000", ...process.argv.slice(2)],
|
|
env: environment,
|
|
stdin: "inherit",
|
|
stdout: "inherit",
|
|
stderr: "inherit",
|
|
})
|
|
const interrupt = () => child.kill("SIGINT")
|
|
const terminate = () => child.kill("SIGTERM")
|
|
process.once("SIGINT", interrupt)
|
|
process.once("SIGTERM", terminate)
|
|
const result = await child.exited
|
|
process.off("SIGINT", interrupt)
|
|
process.off("SIGTERM", terminate)
|
|
|
|
process.exitCode = result
|