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

推荐订阅源

Engineering at Meta
Engineering at Meta
G
Google Developers Blog
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
I
InfoQ
MyScale Blog
MyScale Blog
V
V2EX
B
Blog
罗磊的独立博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

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: share CLI runtime mock helper · openclaw/openclaw@1...
steipete · 2026-04-24 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -2,28 +2,9 @@ import { Command } from "commander";

22

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

33

import { registerDirectoryCli } from "./directory-cli.js";

44
5-

const runtimeState = vi.hoisted(() => {

6-

const runtimeLogs: string[] = [];

7-

const runtimeErrors: string[] = [];

8-

const stringifyArgs = (args: unknown[]) => args.map((value) => String(value)).join(" ");

9-

const defaultRuntime = {

10-

log: vi.fn((...args: unknown[]) => {

11-

runtimeLogs.push(stringifyArgs(args));

12-

}),

13-

error: vi.fn((...args: unknown[]) => {

14-

runtimeErrors.push(stringifyArgs(args));

15-

}),

16-

writeStdout: vi.fn((value: string) => {

17-

defaultRuntime.log(value.endsWith("\n") ? value.slice(0, -1) : value);

18-

}),

19-

writeJson: vi.fn((value: unknown, space = 2) => {

20-

defaultRuntime.log(JSON.stringify(value, null, space > 0 ? space : undefined));

21-

}),

22-

exit: vi.fn((code: number) => {

23-

throw new Error(`exit:${code}`);

24-

}),

25-

};

26-

return { defaultRuntime, runtimeLogs, runtimeErrors };

5+

const runtimeState = await vi.hoisted(async () => {

6+

const { createCliRuntimeMock } = await import("./test-runtime-mock.js");

7+

return createCliRuntimeMock(vi, { exitPrefix: "exit" });

278

});

289
2910

const mocks = vi.hoisted(() => ({

Original file line numberDiff line numberDiff line change

@@ -5,37 +5,17 @@ import { Command } from "commander";

55

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

66

import { registerSecretsCli } from "./secrets-cli.js";

77
8-

const mocks = vi.hoisted(() => {

9-

const runtimeLogs: string[] = [];

10-

const runtimeErrors: string[] = [];

11-

const stringifyArgs = (args: unknown[]) => args.map((value) => String(value)).join(" ");

12-

const defaultRuntime = {

13-

log: vi.fn((...args: unknown[]) => {

14-

runtimeLogs.push(stringifyArgs(args));

15-

}),

16-

error: vi.fn((...args: unknown[]) => {

17-

runtimeErrors.push(stringifyArgs(args));

18-

}),

19-

writeStdout: vi.fn((value: string) => {

20-

defaultRuntime.log(value.endsWith("\n") ? value.slice(0, -1) : value);

21-

}),

22-

writeJson: vi.fn((value: unknown, space = 2) => {

23-

defaultRuntime.log(JSON.stringify(value, null, space > 0 ? space : undefined));

24-

}),

25-

exit: vi.fn((code: number) => {

26-

throw new Error(`__exit__:${code}`);

27-

}),

28-

};

8+

const mocks = await vi.hoisted(async () => {

9+

const { createCliRuntimeMock } = await import("./test-runtime-mock.js");

10+

const runtime = createCliRuntimeMock(vi);

2911

return {

3012

callGatewayFromCli: vi.fn(),

3113

runSecretsAudit: vi.fn(),

3214

resolveSecretsAuditExitCode: vi.fn(),

3315

runSecretsConfigureInteractive: vi.fn(),

3416

runSecretsApply: vi.fn(),

3517

confirm: vi.fn(),

36-

defaultRuntime,

37-

runtimeLogs,

38-

runtimeErrors,

18+

...runtime,

3919

};

4020

});

4121
Original file line numberDiff line numberDiff line change

@@ -0,0 +1,36 @@

1+

import type { vi } from "vitest";

2+
3+

type ViLike = Pick<typeof vi, "fn">;

4+
5+

export function createCliRuntimeMock(

6+

viInstance: ViLike,

7+

options: {

8+

exitPrefix?: string;

9+

} = {},

10+

) {

11+

const runtimeLogs: string[] = [];

12+

const runtimeErrors: string[] = [];

13+

const stringifyArgs = (args: unknown[]) => args.map((value) => String(value)).join(" ");

14+

const defaultRuntime = {

15+

log: viInstance.fn((...args: unknown[]) => {

16+

runtimeLogs.push(stringifyArgs(args));

17+

}),

18+

error: viInstance.fn((...args: unknown[]) => {

19+

runtimeErrors.push(stringifyArgs(args));

20+

}),

21+

writeStdout: viInstance.fn((value: string) => {

22+

defaultRuntime.log(value.endsWith("\n") ? value.slice(0, -1) : value);

23+

}),

24+

writeJson: viInstance.fn((value: unknown, space = 2) => {

25+

defaultRuntime.log(JSON.stringify(value, null, space > 0 ? space : undefined));

26+

}),

27+

exit: viInstance.fn((code: number) => {

28+

throw new Error(`${options.exitPrefix ?? "__exit__"}:${code}`);

29+

}),

30+

};

31+

return {

32+

defaultRuntime,

33+

runtimeLogs,

34+

runtimeErrors,

35+

};

36+

}