惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
J
Java Code Geeks
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
MongoDB | Blog
MongoDB | Blog
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
雷峰网
雷峰网
D
DataBreaches.Net
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: centralize isolated test env writes · openclaw/openc...
shakkernerd · 2026-06-25 · via Recent Commits to openclaw:main

@@ -5,6 +5,7 @@ import { createRequire } from "node:module";

55

import os from "node:os";

66

import path from "node:path";

77

import JSON5 from "json5";

8+

import { deleteTestEnvValue, setTestEnvValue } from "../src/test-utils/env.js";

89910

type RestoreEntry = { key: string; value: string | undefined };

1011

@@ -44,9 +45,9 @@ function isTruthyEnvValue(value: string | undefined): boolean {

4445

function restoreEnv(entries: RestoreEntry[]): void {

4546

for (const { key, value } of entries) {

4647

if (value === undefined) {

47-

delete process.env[key];

48+

deleteTestEnvValue(key);

4849

} else {

49-

process.env[key] = value;

50+

setTestEnvValue(key, value);

5051

}

5152

}

5253

}

@@ -90,7 +91,7 @@ function loadProfileEnv(homeDir = os.homedir()): void {

9091

if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(key) || (process.env[key] ?? "") !== "") {

9192

return false;

9293

}

93-

process.env[key] = entry.slice(idx + 1);

94+

setTestEnvValue(key, entry.slice(idx + 1));

9495

return true;

9596

};

9697

const countAppliedEntries = (entries: Iterable<string>) => {

@@ -193,45 +194,45 @@ function createIsolatedTestHome(restore: RestoreEntry[]): {

193194

} {

194195

const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-test-home-"));

195196196-

process.env.HOME = tempHome;

197-

process.env.USERPROFILE = tempHome;

198-

process.env.OPENCLAW_TEST_HOME = tempHome;

199-

process.env.OPENCLAW_TEST_FAST = "1";

200-

process.env.OPENCLAW_STRICT_FAST_REPLY_CONFIG = "1";

201-

delete process.env.OPENCLAW_ALLOW_SLOW_REPLY_TESTS;

197+

setTestEnvValue("HOME", tempHome);

198+

setTestEnvValue("USERPROFILE", tempHome);

199+

setTestEnvValue("OPENCLAW_TEST_HOME", tempHome);

200+

setTestEnvValue("OPENCLAW_TEST_FAST", "1");

201+

setTestEnvValue("OPENCLAW_STRICT_FAST_REPLY_CONFIG", "1");

202+

deleteTestEnvValue("OPENCLAW_ALLOW_SLOW_REPLY_TESTS");

202203203204

// Ensure test runs never touch the developer's real config/state, even if they have overrides set.

204-

delete process.env.OPENCLAW_CONFIG_PATH;

205+

deleteTestEnvValue("OPENCLAW_CONFIG_PATH");

205206

// Prefer deriving state dir from HOME so nested tests that change HOME also isolate correctly.

206-

delete process.env.OPENCLAW_STATE_DIR;

207-

delete process.env.OPENCLAW_AGENT_DIR;

207+

deleteTestEnvValue("OPENCLAW_STATE_DIR");

208+

deleteTestEnvValue("OPENCLAW_AGENT_DIR");

208209

// Prefer test-controlled ports over developer overrides (avoid port collisions across tests/workers).

209-

delete process.env.OPENCLAW_GATEWAY_PORT;

210-

delete process.env.OPENCLAW_BRIDGE_ENABLED;

211-

delete process.env.OPENCLAW_BRIDGE_HOST;

212-

delete process.env.OPENCLAW_BRIDGE_PORT;

213-

delete process.env.OPENCLAW_CANVAS_HOST_PORT;

210+

deleteTestEnvValue("OPENCLAW_GATEWAY_PORT");

211+

deleteTestEnvValue("OPENCLAW_BRIDGE_ENABLED");

212+

deleteTestEnvValue("OPENCLAW_BRIDGE_HOST");

213+

deleteTestEnvValue("OPENCLAW_BRIDGE_PORT");

214+

deleteTestEnvValue("OPENCLAW_CANVAS_HOST_PORT");

214215

// Avoid leaking real GitHub/Copilot tokens into non-live test runs.

215-

delete process.env.TELEGRAM_BOT_TOKEN;

216-

delete process.env.DISCORD_BOT_TOKEN;

217-

delete process.env.SLACK_BOT_TOKEN;

218-

delete process.env.SLACK_APP_TOKEN;

219-

delete process.env.SLACK_USER_TOKEN;

220-

delete process.env.COPILOT_GITHUB_TOKEN;

221-

delete process.env.GH_TOKEN;

222-

delete process.env.GITHUB_TOKEN;

216+

deleteTestEnvValue("TELEGRAM_BOT_TOKEN");

217+

deleteTestEnvValue("DISCORD_BOT_TOKEN");

218+

deleteTestEnvValue("SLACK_BOT_TOKEN");

219+

deleteTestEnvValue("SLACK_APP_TOKEN");

220+

deleteTestEnvValue("SLACK_USER_TOKEN");

221+

deleteTestEnvValue("COPILOT_GITHUB_TOKEN");

222+

deleteTestEnvValue("GH_TOKEN");

223+

deleteTestEnvValue("GITHUB_TOKEN");

223224

// Avoid leaking local dev tooling flags into tests (e.g. --inspect).

224-

delete process.env.NODE_OPTIONS;

225+

deleteTestEnvValue("NODE_OPTIONS");

225226226227

// Windows: prefer the default state dir so auth/profile tests match real paths.

227228

if (process.platform === "win32") {

228-

process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");

229+

setTestEnvValue("OPENCLAW_STATE_DIR", path.join(tempHome, ".openclaw"));

229230

}

230231231-

process.env.XDG_CONFIG_HOME = path.join(tempHome, ".config");

232-

process.env.XDG_DATA_HOME = path.join(tempHome, ".local", "share");

233-

process.env.XDG_STATE_HOME = path.join(tempHome, ".local", "state");

234-

process.env.XDG_CACHE_HOME = path.join(tempHome, ".cache");

232+

setTestEnvValue("XDG_CONFIG_HOME", path.join(tempHome, ".config"));

233+

setTestEnvValue("XDG_DATA_HOME", path.join(tempHome, ".local", "share"));

234+

setTestEnvValue("XDG_STATE_HOME", path.join(tempHome, ".local", "state"));

235+

setTestEnvValue("XDG_CACHE_HOME", path.join(tempHome, ".cache"));

235236236237

const cleanup = () => {

237238

restoreEnv(restore);