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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
月光博客
月光博客
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Jina AI
Jina AI
小众软件
小众软件
U
Unit 42
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
B
Blog
C
Check Point Blog
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
量子位
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell

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
test(cli): isolate service env in run and update suites ·...
kklouzal · 2026-06-24 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,11 +1,11 @@

11

// Gateway run option collision tests cover gateway run flag registration boundaries.

22

import path from "node:path";

33

import { Command } from "commander";

4-

import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

4+

import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

55

import type { ConfigFileSnapshot } from "../../config/types.js";

66

import { GATEWAY_SERVICE_RUNTIME_PID_ENV } from "../../daemon/constants.js";

77

import { SUPERVISOR_HINT_ENV_VARS } from "../../infra/supervisor-markers.js";

8-

import { withEnvAsync } from "../../test-utils/env.js";

8+

import { captureEnv, withEnvAsync } from "../../test-utils/env.js";

99

import { withTempSecretFiles } from "../../test-utils/secret-file-fixture.js";

1010

import { createCliRuntimeCapture } from "../test-runtime-capture.js";

1111

import { installGatewayRunRuntimeHooks } from "./runtime-hooks.js";

@@ -96,6 +96,11 @@ const withoutGatewayAuthEnv = {

9696

};

9797
9898

const { runtimeErrors, defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();

99+

const serviceEnvSnapshot = captureEnv([

100+

"OPENCLAW_SERVICE_MARKER",

101+

"OPENCLAW_SERVICE_KIND",

102+

GATEWAY_SERVICE_RUNTIME_PID_ENV,

103+

]);

99104
100105

vi.mock("../../config/config.js", () => ({

101106

getConfigPath: () => "/tmp/openclaw-test-missing-config.json",

@@ -287,7 +292,14 @@ describe("gateway run option collisions", () => {

287292

addGatewayRunCommand(gateway.command("run"), { beforeRun });

288293

});

289294
295+

afterAll(() => {

296+

serviceEnvSnapshot.restore();

297+

});

298+
290299

beforeEach(() => {

300+

delete process.env.OPENCLAW_SERVICE_MARKER;

301+

delete process.env.OPENCLAW_SERVICE_KIND;

302+

delete process.env[GATEWAY_SERVICE_RUNTIME_PID_ENV];

291303

resetRuntimeCapture();

292304

configState.cfg = {};

293305

configState.snapshot = { config: {}, exists: false, sourceConfig: {}, valid: true };

Original file line numberDiff line numberDiff line change

@@ -4,9 +4,10 @@ import os from "node:os";

44

import path from "node:path";

55

import process from "node:process";

66

import { CommanderError } from "commander";

7-

import { beforeEach, describe, expect, it, vi } from "vitest";

7+

import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";

8+

import { GATEWAY_SERVICE_RUNTIME_PID_ENV } from "../daemon/constants.js";

89

import { loggingState } from "../logging/state.js";

9-

import { withEnvAsync } from "../test-utils/env.js";

10+

import { captureEnv, withEnvAsync } from "../test-utils/env.js";

1011

import { getGatewayRunRuntimeHooks } from "./gateway-cli/runtime-hooks.js";

1112

import type { RootHelpRenderOptions } from "./program/root-help.js";

1213

import { runCli, shouldStartProxyForCli } from "./run-main.js";

@@ -107,6 +108,11 @@ const maybeRunCliInContainerMock = vi.hoisted(() =>

107108

(argv: string[]) => { handled: true; exitCode: number } | { handled: false; argv: string[] }

108109

>((argv: string[]) => ({ handled: false, argv })),

109110

);

111+

const serviceEnvSnapshot = captureEnv([

112+

"OPENCLAW_SERVICE_MARKER",

113+

"OPENCLAW_SERVICE_KIND",

114+

GATEWAY_SERVICE_RUNTIME_PID_ENV,

115+

]);

110116
111117

function requireRunCrestodianOptions(index = 0): { onReady?: unknown } {

112118

const call = runCrestodianMock.mock.calls[index];

@@ -346,7 +352,14 @@ async function withInteractiveTty(fn: () => Promise<void>): Promise<void> {

346352

}

347353
348354

describe("runCli exit behavior", () => {

355+

afterAll(() => {

356+

serviceEnvSnapshot.restore();

357+

});

358+
349359

beforeEach(() => {

360+

delete process.env.OPENCLAW_SERVICE_MARKER;

361+

delete process.env.OPENCLAW_SERVICE_KIND;

362+

delete process.env[GATEWAY_SERVICE_RUNTIME_PID_ENV];

350363

vi.clearAllMocks();

351364

readConfigFileSnapshotMock.mockResolvedValue({

352365

exists: true,

Original file line numberDiff line numberDiff line change

@@ -5,7 +5,7 @@ import fs from "node:fs/promises";

55

import os from "node:os";

66

import path from "node:path";

77

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";

99

import { TEST_BUNDLED_RUNTIME_SIDECAR_PATHS } from "../../test/helpers/bundled-runtime-sidecars.js";

1010

import type { OpenClawConfig, ConfigFileSnapshot } from "../config/types.openclaw.js";

1111

import type { PluginInstallRecord } from "../config/types.plugins.js";

@@ -19,7 +19,7 @@ import {

1919

writeUpdatePostInstallDoctorResult,

2020

} from "../infra/update-doctor-result.js";

2121

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";

2323

import { VERSION } from "../version.js";

2424

import { createCliRuntimeCapture } from "./test-runtime-capture.js";

2525

import { isOwningNpmCommand } from "./update-cli.test-helpers.js";

@@ -70,6 +70,11 @@ const execFile = vi.fn((...args: unknown[]) => {

7070

});

7171

const spawn = vi.fn();

7272

const { defaultRuntime: runtimeCapture, resetRuntimeCapture } = createCliRuntimeCapture();

73+

const serviceEnvSnapshot = captureEnv([

74+

"OPENCLAW_SERVICE_MARKER",

75+

"OPENCLAW_SERVICE_KIND",

76+

GATEWAY_SERVICE_RUNTIME_PID_ENV,

77+

]);

7378
7479

vi.mock("@clack/prompts", () => ({

7580

confirm,

@@ -716,6 +721,9 @@ describe("update-cli", () => {

716721

};

717722
718723

beforeEach(() => {

724+

delete process.env.OPENCLAW_SERVICE_MARKER;

725+

delete process.env.OPENCLAW_SERVICE_KIND;

726+

delete process.env[GATEWAY_SERVICE_RUNTIME_PID_ENV];

719727

vi.clearAllMocks();

720728

resetRuntimeCapture();

721729

spawn.mockImplementation(() => {

@@ -874,6 +882,10 @@ describe("update-cli", () => {

874882

setStdoutTty(false);

875883

});

876884
885+

afterAll(() => {

886+

serviceEnvSnapshot.restore();

887+

});

888+
877889

afterEach(async () => {

878890

if (tempDirsToCleanup.size === 0) {

879891

return;