perf(test): speed up setup and config path resolution
This commit is contained in:
@@ -9,15 +9,11 @@ import {
|
||||
import { fetchTelegramChatId } from "../channels/telegram/api.js";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import {
|
||||
OpenClawSchema,
|
||||
CONFIG_PATH,
|
||||
migrateLegacyConfig,
|
||||
readConfigFileSnapshot,
|
||||
} from "../config/config.js";
|
||||
import { CONFIG_PATH, migrateLegacyConfig, readConfigFileSnapshot } from "../config/config.js";
|
||||
import { collectProviderDangerousNameMatchingScopes } from "../config/dangerous-name-matching.js";
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import { parseToolsBySenderTypedKey } from "../config/types.tools.js";
|
||||
import { OpenClawSchema } from "../config/zod-schema.js";
|
||||
import { resolveCommandResolutionFromArgv } from "../infra/exec-command-resolution.js";
|
||||
import {
|
||||
listInterpreterLikeSafeBins,
|
||||
|
||||
@@ -21,4 +21,3 @@ export {
|
||||
validateConfigObjectRawWithPlugins,
|
||||
validateConfigObjectWithPlugins,
|
||||
} from "./validation.js";
|
||||
export { OpenClawSchema } from "./zod-schema.js";
|
||||
|
||||
@@ -67,6 +67,9 @@ export function resolveStateDir(
|
||||
return resolveUserPath(override, env, effectiveHomedir);
|
||||
}
|
||||
const newDir = newStateDir(effectiveHomedir);
|
||||
if (env.OPENCLAW_TEST_FAST === "1") {
|
||||
return newDir;
|
||||
}
|
||||
const legacyDirs = legacyStateDirs(effectiveHomedir);
|
||||
const hasNew = fs.existsSync(newDir);
|
||||
if (hasNew) {
|
||||
@@ -131,6 +134,9 @@ export function resolveConfigPathCandidate(
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
homedir: () => string = envHomedir(env),
|
||||
): string {
|
||||
if (env.OPENCLAW_TEST_FAST === "1") {
|
||||
return resolveCanonicalConfigPath(env, resolveStateDir(env, homedir));
|
||||
}
|
||||
const candidates = resolveDefaultConfigCandidates(env, homedir);
|
||||
const existing = candidates.find((candidate) => {
|
||||
try {
|
||||
@@ -157,6 +163,9 @@ export function resolveConfigPath(
|
||||
if (override) {
|
||||
return resolveUserPath(override, env, homedir);
|
||||
}
|
||||
if (env.OPENCLAW_TEST_FAST === "1") {
|
||||
return path.join(stateDir, CONFIG_FILENAME);
|
||||
}
|
||||
const stateOverride = env.OPENCLAW_STATE_DIR?.trim();
|
||||
const candidates = [
|
||||
path.join(stateDir, CONFIG_FILENAME),
|
||||
|
||||
Reference in New Issue
Block a user