
























@@ -9,7 +9,7 @@ import { clearConfigCache, clearRuntimeConfigSnapshot } from "../config/config.j
99import { clearSessionStoreCacheForTest } from "../config/sessions/store.js";
1010import { resetAgentRunContextForTest } from "../infra/agent-events.js";
1111import { clearGatewaySubagentRuntime } from "../plugins/runtime/index.js";
12-import { captureEnv } from "../test-utils/env.js";
12+import { captureEnv, deleteTestEnvValue, setTestEnvValue } from "../test-utils/env.js";
1313import { startGatewayServer } from "./server.js";
1414import {
1515connectDeviceAuthReq,
@@ -136,25 +136,25 @@ async function setupGatewayTempHome(params: { prefix: string; minimalGateway?: b
136136]);
137137138138const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), params.prefix));
139-process.env.HOME = tempHome;
140-process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");
141-delete process.env.OPENCLAW_CONFIG_PATH;
142-process.env.OPENCLAW_SKIP_CHANNELS = "1";
143-process.env.OPENCLAW_SKIP_GMAIL_WATCHER = "1";
144-process.env.OPENCLAW_SKIP_CRON = "1";
145-process.env.OPENCLAW_SKIP_CANVAS_HOST = "1";
146-process.env.OPENCLAW_SKIP_BROWSER_CONTROL_SERVER = "1";
147-process.env.OPENCLAW_SKIP_PROVIDERS = "1";
139+setTestEnvValue("HOME", tempHome);
140+setTestEnvValue("OPENCLAW_STATE_DIR", path.join(tempHome, ".openclaw"));
141+deleteTestEnvValue("OPENCLAW_CONFIG_PATH");
142+setTestEnvValue("OPENCLAW_SKIP_CHANNELS", "1");
143+setTestEnvValue("OPENCLAW_SKIP_GMAIL_WATCHER", "1");
144+setTestEnvValue("OPENCLAW_SKIP_CRON", "1");
145+setTestEnvValue("OPENCLAW_SKIP_CANVAS_HOST", "1");
146+setTestEnvValue("OPENCLAW_SKIP_BROWSER_CONTROL_SERVER", "1");
147+setTestEnvValue("OPENCLAW_SKIP_PROVIDERS", "1");
148148if (params.minimalGateway) {
149-process.env.OPENCLAW_TEST_MINIMAL_GATEWAY = "1";
149+setTestEnvValue("OPENCLAW_TEST_MINIMAL_GATEWAY", "1");
150150} else {
151-delete process.env.OPENCLAW_TEST_MINIMAL_GATEWAY;
151+deleteTestEnvValue("OPENCLAW_TEST_MINIMAL_GATEWAY");
152152}
153153154154const workspaceDir = path.join(tempHome, "openclaw");
155155await fs.mkdir(workspaceDir, { recursive: true });
156-process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = await createEmptyBundledPluginsDir(tempHome);
157-process.env.OPENCLAW_DISABLE_BUNDLED_PLUGINS = "1";
156+setTestEnvValue("OPENCLAW_BUNDLED_PLUGINS_DIR", await createEmptyBundledPluginsDir(tempHome));
157+setTestEnvValue("OPENCLAW_DISABLE_BUNDLED_PLUGINS", "1");
158158return { envSnapshot, tempHome, workspaceDir };
159159}
160160@@ -187,7 +187,7 @@ describe("gateway e2e", () => {
187187});
188188189189const token = nextGatewayId("test-token");
190-process.env.OPENCLAW_GATEWAY_TOKEN = token;
190+setTestEnvValue("OPENCLAW_GATEWAY_TOKEN", token);
191191192192const configPath = await createGatewayConfigPath(tempHome);
193193const mockProvider = buildMockOpenAiResponsesProvider(openaiBaseUrl);
@@ -299,7 +299,7 @@ module.exports = {
299299gateway: { auth: { token } },
300300};
301301await fs.writeFile(configPath, `${JSON.stringify(cfg, null, 2)}\n`);
302-process.env.OPENCLAW_CONFIG_PATH = configPath;
302+setTestEnvValue("OPENCLAW_CONFIG_PATH", configPath);
303303304304const { port, server } = await startLoopbackTokenGateway(token);
305305@@ -344,10 +344,10 @@ module.exports = {
344344prefix: "openclaw-wizard-home-",
345345minimalGateway: true,
346346});
347-delete process.env.OPENCLAW_GATEWAY_TOKEN;
347+deleteTestEnvValue("OPENCLAW_GATEWAY_TOKEN");
348348349349const configPath = await createGatewayConfigPath(tempHome);
350-process.env.OPENCLAW_CONFIG_PATH = configPath;
350+setTestEnvValue("OPENCLAW_CONFIG_PATH", configPath);
351351clearRuntimeConfigSnapshot();
352352clearConfigCache();
353353@@ -481,21 +481,21 @@ module.exports = {
481481const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-minimal-gateway-home-"));
482482const configPath = await createGatewayConfigPath(tempHome);
483483const bundledPluginsDir = path.join(tempHome, "openclaw-test-no-bundled-extensions");
484-process.env.HOME = tempHome;
485-process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");
486-process.env.OPENCLAW_CONFIG_PATH = configPath;
487-process.env.OPENCLAW_SKIP_CHANNELS = "1";
488-process.env.OPENCLAW_SKIP_GMAIL_WATCHER = "1";
489-process.env.OPENCLAW_SKIP_CRON = "1";
490-process.env.OPENCLAW_SKIP_CANVAS_HOST = "1";
491-process.env.OPENCLAW_SKIP_BROWSER_CONTROL_SERVER = "1";
492-process.env.OPENCLAW_SKIP_PROVIDERS = "1";
493-process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir;
494-process.env.OPENCLAW_TEST_MINIMAL_GATEWAY = "1";
495-process.env.DISCORD_BOT_TOKEN = "discord-test-token";
484+setTestEnvValue("HOME", tempHome);
485+setTestEnvValue("OPENCLAW_STATE_DIR", path.join(tempHome, ".openclaw"));
486+setTestEnvValue("OPENCLAW_CONFIG_PATH", configPath);
487+setTestEnvValue("OPENCLAW_SKIP_CHANNELS", "1");
488+setTestEnvValue("OPENCLAW_SKIP_GMAIL_WATCHER", "1");
489+setTestEnvValue("OPENCLAW_SKIP_CRON", "1");
490+setTestEnvValue("OPENCLAW_SKIP_CANVAS_HOST", "1");
491+setTestEnvValue("OPENCLAW_SKIP_BROWSER_CONTROL_SERVER", "1");
492+setTestEnvValue("OPENCLAW_SKIP_PROVIDERS", "1");
493+setTestEnvValue("OPENCLAW_BUNDLED_PLUGINS_DIR", bundledPluginsDir);
494+setTestEnvValue("OPENCLAW_TEST_MINIMAL_GATEWAY", "1");
495+setTestEnvValue("DISCORD_BOT_TOKEN", "discord-test-token");
496496497497const token = nextGatewayId("minimal-token");
498-process.env.OPENCLAW_GATEWAY_TOKEN = token;
498+setTestEnvValue("OPENCLAW_GATEWAY_TOKEN", token);
499499await fs.mkdir(bundledPluginsDir, { recursive: true });
500500await fs.writeFile(
501501configPath,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。