@@ -5,7 +5,7 @@ import fs from "node:fs/promises";
|
5 | 5 | import os from "node:os"; |
6 | 6 | import path from "node:path"; |
7 | 7 | import { Command } from "commander"; |
8 | | -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
| 8 | +import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
9 | 9 | import { TEST_BUNDLED_RUNTIME_SIDECAR_PATHS } from "../../test/helpers/bundled-runtime-sidecars.js"; |
10 | 10 | import type { OpenClawConfig, ConfigFileSnapshot } from "../config/types.openclaw.js"; |
11 | 11 | import type { PluginInstallRecord } from "../config/types.plugins.js"; |
@@ -19,7 +19,7 @@ import {
|
19 | 19 | writeUpdatePostInstallDoctorResult, |
20 | 20 | } from "../infra/update-doctor-result.js"; |
21 | 21 | import type { UpdateRunResult } from "../infra/update-runner.js"; |
22 | | -import { withEnvAsync } from "../test-utils/env.js"; |
| 22 | +import { captureEnv, withEnvAsync } from "../test-utils/env.js"; |
23 | 23 | import { VERSION } from "../version.js"; |
24 | 24 | import { createCliRuntimeCapture } from "./test-runtime-capture.js"; |
25 | 25 | import { isOwningNpmCommand } from "./update-cli.test-helpers.js"; |
@@ -70,6 +70,11 @@ const execFile = vi.fn((...args: unknown[]) => {
|
70 | 70 | }); |
71 | 71 | const spawn = vi.fn(); |
72 | 72 | const { defaultRuntime: runtimeCapture, resetRuntimeCapture } = createCliRuntimeCapture(); |
| 73 | +const serviceEnvSnapshot = captureEnv([ |
| 74 | +"OPENCLAW_SERVICE_MARKER", |
| 75 | +"OPENCLAW_SERVICE_KIND", |
| 76 | +GATEWAY_SERVICE_RUNTIME_PID_ENV, |
| 77 | +]); |
73 | 78 | |
74 | 79 | vi.mock("@clack/prompts", () => ({ |
75 | 80 | confirm, |
@@ -716,6 +721,9 @@ describe("update-cli", () => {
|
716 | 721 | }; |
717 | 722 | |
718 | 723 | beforeEach(() => { |
| 724 | +delete process.env.OPENCLAW_SERVICE_MARKER; |
| 725 | +delete process.env.OPENCLAW_SERVICE_KIND; |
| 726 | +delete process.env[GATEWAY_SERVICE_RUNTIME_PID_ENV]; |
719 | 727 | vi.clearAllMocks(); |
720 | 728 | resetRuntimeCapture(); |
721 | 729 | spawn.mockImplementation(() => { |
@@ -874,6 +882,10 @@ describe("update-cli", () => {
|
874 | 882 | setStdoutTty(false); |
875 | 883 | }); |
876 | 884 | |
| 885 | +afterAll(() => { |
| 886 | +serviceEnvSnapshot.restore(); |
| 887 | +}); |
| 888 | + |
877 | 889 | afterEach(async () => { |
878 | 890 | if (tempDirsToCleanup.size === 0) { |
879 | 891 | return; |
|