





























@@ -5,7 +5,12 @@ import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vites
55import type { ConfigFileSnapshot } from "../../config/types.js";
66import { GATEWAY_SERVICE_RUNTIME_PID_ENV } from "../../daemon/constants.js";
77import { SUPERVISOR_HINT_ENV_VARS } from "../../infra/supervisor-markers.js";
8-import { captureEnv, withEnvAsync } from "../../test-utils/env.js";
8+import {
9+captureEnv,
10+deleteTestEnvValue,
11+setTestEnvValue,
12+withEnvAsync,
13+} from "../../test-utils/env.js";
914import { withTempSecretFiles } from "../../test-utils/secret-file-fixture.js";
1015import { createCliRuntimeCapture } from "../test-runtime-capture.js";
1116import { installGatewayRunRuntimeHooks } from "./runtime-hooks.js";
@@ -299,7 +304,7 @@ describe("gateway run option collisions", () => {
299304beforeEach(() => {
300305delete process.env.OPENCLAW_SERVICE_MARKER;
301306delete process.env.OPENCLAW_SERVICE_KIND;
302-delete process.env[GATEWAY_SERVICE_RUNTIME_PID_ENV];
307+deleteTestEnvValue(GATEWAY_SERVICE_RUNTIME_PID_ENV);
303308resetRuntimeCapture();
304309configState.cfg = {};
305310configState.snapshot = { config: {}, exists: false, sourceConfig: {}, valid: true };
@@ -1035,7 +1040,9 @@ describe("gateway run option collisions", () => {
10351040loadGlobalRuntimeDotEnvFiles.mockImplementation(() => {
10361041process.env.OPENCLAW_GATEWAY_TOKEN ??= "trusted-token";
10371042process.env.OPENCLAW_PROFILE ??= "dev";
1038-process.env.OPENCLAW_WORKSPACE_DIR ??= "/tmp/openclaw-reset-workspace";
1043+if (process.env.OPENCLAW_WORKSPACE_DIR === undefined) {
1044+setTestEnvValue("OPENCLAW_WORKSPACE_DIR", "/tmp/openclaw-reset-workspace");
1045+}
10391046});
1040104710411048await prepareGatewayReset();
@@ -1059,7 +1066,7 @@ describe("gateway run option collisions", () => {
10591066};
10601067await prepareGatewayReset();
10611068loadGlobalRuntimeDotEnvFiles.mockImplementation(() => {
1062-process.env.OPENCLAW_STATE_DIR = "/tmp/openclaw-reset-retargeted";
1069+setTestEnvValue("OPENCLAW_STATE_DIR", "/tmp/openclaw-reset-retargeted");
10631070return {
10641071gatewayEnvAppliedKeys: [],
10651072stateEnvAppliedKeys: ["OPENCLAW_STATE_DIR"],
@@ -1091,7 +1098,7 @@ describe("gateway run option collisions", () => {
10911098])("blocks trusted dotenv selector drift for %s after startup mutations", async (selector) => {
10921099await withEnvAsync({ [selector]: "/tmp/openclaw-reset-value" }, async () => {
10931100loadGlobalRuntimeDotEnvFiles.mockImplementation(() => {
1094-process.env[selector] = "/tmp/openclaw-reset-retargeted";
1101+setTestEnvValue(selector, "/tmp/openclaw-reset-retargeted");
10951102});
10961103const { reloadTrustedGatewayRunEnvironment } = await import("./pre-bootstrap.js");
10971104此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。