fix(test): make legacy-plugin-warning tests isolation-safe

Pass explicit config dir to checkForLegacyPluginEntry instead of relying
on XDG_CONFIG_HOME env var, which gets contaminated by parallel tests on
Linux CI. Also adds missing 'join' import.
This commit is contained in:
YeonGyu-Kim
2026-03-26 19:54:05 +09:00
parent f419a3a925
commit 8e65d6cf2c
2 changed files with 24 additions and 31 deletions
+12 -3
View File
@@ -1,4 +1,5 @@
import { existsSync, readFileSync } from "node:fs"
import { join } from "node:path"
import { parseJsoncSafe } from "./jsonc-parser"
import { getOpenCodeConfigPaths } from "./opencode-config-dir"
@@ -14,7 +15,15 @@ export interface LegacyPluginCheckResult {
legacyEntries: string[]
}
function getOpenCodeConfigPath(): string | null {
function getOpenCodeConfigPath(overrideConfigDir?: string): string | null {
if (overrideConfigDir) {
const jsonPath = join(overrideConfigDir, "opencode.json")
const jsoncPath = join(overrideConfigDir, "opencode.jsonc")
if (existsSync(jsoncPath)) return jsoncPath
if (existsSync(jsonPath)) return jsonPath
return null
}
const { configJsonc, configJson } = getOpenCodeConfigPaths({ binary: "opencode", version: null })
if (existsSync(configJsonc)) return configJsonc
@@ -30,8 +39,8 @@ function isCanonicalPluginEntry(entry: string): boolean {
return entry === PLUGIN_NAME || entry.startsWith(`${PLUGIN_NAME}@`)
}
export function checkForLegacyPluginEntry(): LegacyPluginCheckResult {
const configPath = getOpenCodeConfigPath()
export function checkForLegacyPluginEntry(overrideConfigDir?: string): LegacyPluginCheckResult {
const configPath = getOpenCodeConfigPath(overrideConfigDir)
if (!configPath) {
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [] }
}