





















@@ -4,7 +4,7 @@ import fs from "node:fs";
44import os from "node:os";
55import path from "node:path";
66import { afterEach, beforeEach, describe, expect, it } from "vitest";
7-import { captureEnv } from "../test-utils/env.js";
7+import { captureEnv, setTestEnvValue } from "../test-utils/env.js";
88import {
99maybeWrapCommandWithShellSnapshot,
1010resetShellSnapshotCacheForTests,
@@ -40,9 +40,9 @@ function setSnapshotStateForTest(
4040options: { home?: string; zdotdir?: string } = {},
4141): void {
4242// Snapshot tests mutate trusted process env, not per-command untrusted env.
43-process.env.OPENCLAW_STATE_DIR = stateDir;
43+setTestEnvValue("OPENCLAW_STATE_DIR", stateDir);
4444if (options.home) {
45-process.env.HOME = options.home;
45+setTestEnvValue("HOME", options.home);
4646}
4747if (options.zdotdir) {
4848process.env.ZDOTDIR = options.zdotdir;
@@ -91,7 +91,7 @@ describe("exec shell snapshots", () => {
9191const home = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-snapshot-disabled-home-"));
9292tempDirs.push(stateDir, home);
9393setSnapshotStateForTest(stateDir, { home });
94-process.env[EXEC_SHELL_SNAPSHOT_ENV] = "0";
94+setTestEnvValue(EXEC_SHELL_SNAPSHOT_ENV, "0");
9595const command = "echo unchanged";
9696const wrapped = await maybeWrapCommandWithShellSnapshot({
9797 command,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。