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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
博客园_首页
美团技术团队
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
J
Java Code Geeks
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog
雷峰网
雷峰网
爱范儿
爱范儿

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: guard windows exec mock calls · openclaw/openclaw@f...
steipete · 2026-05-12 · via Recent Commits to openclaw:main

@@ -48,12 +48,14 @@ type MockChild = EventEmitter & {

4848

killed?: boolean;

4949

};

505051-

function spawnCallAt(callIndex: number): unknown[] {

51+

type SpawnCall = [string, string[], Record<string, unknown>];

52+53+

function requireSpawnCall(callIndex: number): SpawnCall {

5254

const call = spawnMock.mock.calls[callIndex];

5355

if (!call) {

5456

throw new Error(`expected spawn call ${callIndex}`);

5557

}

56-

return call;

58+

return call as SpawnCall;

5759

}

58605961

function createMockChild(params?: {

@@ -90,22 +92,25 @@ function createMockChild(params?: {

9092

return child;

9193

}

929493-

type SpawnCall = [string, string[], Record<string, unknown>];

94-9595

type ExecCall = [

9696

string,

9797

string[],

9898

Record<string, unknown>,

9999

(err: Error | null, stdout: string, stderr: string) => void,

100100

];

101101102+

function requireExecFileCall(callIndex: number): ExecCall {

103+

const call = execFileMock.mock.calls[callIndex];

104+

if (!call) {

105+

throw new Error(`expected execFile call ${callIndex}`);

106+

}

107+

return call as ExecCall;

108+

}

109+102110

function expectCmdWrappedInvocation(params: {

103-

captured: SpawnCall | ExecCall | undefined;

111+

captured: SpawnCall | ExecCall;

104112

expectedComSpec: string;

105113

}) {

106-

if (!params.captured) {

107-

throw new Error("expected command wrapper to be called");

108-

}

109114

expect(params.captured[0]).toBe(params.expectedComSpec);

110115

expect(params.captured[1].slice(0, 3)).toEqual(["/d", "/s", "/c"]);

111116

expect(params.captured[1][3]).toContain("pnpm.cmd --version");

@@ -186,7 +191,7 @@ describe("windows command wrapper behavior", () => {

186191

try {

187192

const result = await runCommandWithTimeout(["pnpm", "--version"], { timeoutMs: 1000 });

188193

expect(result.code).toBe(0);

189-

const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;

194+

const captured = requireSpawnCall(0);

190195

expectCmdWrappedInvocation({ captured, expectedComSpec });

191196

} finally {

192197

platformSpy.mockRestore();

@@ -207,7 +212,7 @@ describe("windows command wrapper behavior", () => {

207212

try {

208213

const result = await runCommandWithTimeout(["pnpm", "--version"], { timeoutMs: 1000 });

209214

expect(result.code).toBe(0);

210-

const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;

215+

const captured = requireSpawnCall(0);

211216

expectCmdWrappedInvocation({

212217

captured,

213218

expectedComSpec: path.win32.join("C:\\Windows", "System32", "cmd.exe"),

@@ -254,7 +259,7 @@ describe("windows command wrapper behavior", () => {

254259255260

const result = await runCommandWithTimeout(["pnpm", "--version"], { timeoutMs: 1000 });

256261

expect(result.code).toBe(0);

257-

const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;

262+

const captured = requireSpawnCall(0);

258263

expectCmdWrappedInvocation({

259264

captured,

260265

expectedComSpec: path.win32.join("C:\\Windows", "System32", "cmd.exe"),

@@ -286,10 +291,7 @@ describe("windows command wrapper behavior", () => {

286291

try {

287292

const result = await runCommandWithTimeout(["corepack", "--version"], { timeoutMs: 1000 });

288293

expect(result.code).toBe(0);

289-

const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;

290-

if (!captured) {

291-

throw new Error("expected corepack shim spawn");

292-

}

294+

const captured = requireSpawnCall(0);

293295

expect(captured[0]).toBe(expectedComSpec);

294296

expect(captured[1].slice(0, 3)).toEqual(["/d", "/s", "/c"]);

295297

expect(captured[1][3]).toContain("corepack.cmd --version");

@@ -324,10 +326,7 @@ describe("windows command wrapper behavior", () => {

324326

try {

325327

const result = await runCommandWithTimeout(["npm", "--version"], { timeoutMs: 1000 });

326328

expect(result.code).toBe(0);

327-

const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;

328-

if (!captured) {

329-

throw new Error("expected npm shim spawn");

330-

}

329+

const captured = requireSpawnCall(0);

331330

expect(captured[0]).toBe(process.execPath);

332331

expect(captured[1][0]).toBe(

333332

path.join(path.dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js"),

@@ -354,10 +353,7 @@ describe("windows command wrapper behavior", () => {

354353

try {

355354

const result = await runCommandWithTimeout(["npm", "--version"], { timeoutMs: 1000 });

356355

expect(result.code).toBe(0);

357-

const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;

358-

if (!captured) {

359-

throw new Error("expected npm.cmd fallback spawn");

360-

}

356+

const captured = requireSpawnCall(0);

361357

expect(captured[0]).toBe(expectedComSpec);

362358

expect(captured[1].slice(0, 3)).toEqual(["/d", "/s", "/c"]);

363359

expect(captured[1][3]).toContain("npm.cmd --version");

@@ -414,7 +410,7 @@ describe("windows command wrapper behavior", () => {

414410415411

try {

416412

await runExec("pnpm", ["--version"], 1000);

417-

const captured = execFileMock.mock.calls[0] as ExecCall | undefined;

413+

const captured = requireExecFileCall(0);

418414

expectCmdWrappedInvocation({ captured, expectedComSpec });

419415

} finally {

420416

platformSpy.mockRestore();

@@ -437,10 +433,7 @@ describe("windows command wrapper behavior", () => {

437433438434

try {

439435

await runExec("node", ["--version"], 1000);

440-

const captured = execFileMock.mock.calls[0] as ExecCall | undefined;

441-

if (!captured) {

442-

throw new Error("expected direct execFile invocation");

443-

}

436+

const captured = requireExecFileCall(0);

444437

expect(captured[0]).toBe("node");

445438

expect(captured[1]).toEqual(["--version"]);

446439

expect(captured[2].windowsHide).toBe(true);

@@ -459,10 +452,7 @@ describe("windows command wrapper behavior", () => {

459452

try {

460453

const result = await runCommandWithTimeout(["node", "--version"], { timeoutMs: 1000 });

461454

expect(result.code).toBe(0);

462-

const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;

463-

if (!captured) {

464-

throw new Error("expected direct spawn invocation");

465-

}

455+

const captured = requireSpawnCall(0);

466456

expect(captured[0]).toBe("node");

467457

expect(captured[1]).toEqual(["--version"]);

468458

expect(captured[2].windowsHide).toBe(true);

@@ -486,7 +476,7 @@ describe("windows command wrapper behavior", () => {

486476

await vi.advanceTimersByTimeAsync(81);

487477

expect(child.kill).not.toHaveBeenCalled();

488478

expect(spawnMock).toHaveBeenCalledTimes(2);

489-

const taskkillCall = spawnCallAt(1);

479+

const taskkillCall = requireSpawnCall(1);

490480

expect(taskkillCall[0]).toBe("taskkill");

491481

expect(taskkillCall[1]).toEqual(["/PID", "1234", "/T", "/F"]);

492482

expect(taskkillCall[2]).toEqual({

@@ -524,8 +514,8 @@ describe("windows command wrapper behavior", () => {

524514

const result = await runExec("node", ["gbk-output.js"], 1000);

525515

expect(result.stdout).toBe("测试");

526516

expect(result.stderr).toBe(";");

527-

const captured = execFileMock.mock.calls[0] as ExecCall | undefined;

528-

expect(captured?.[2].encoding).toBe("buffer");

517+

const captured = requireExecFileCall(0);

518+

expect(captured[2].encoding).toBe("buffer");

529519

} finally {

530520

platformSpy.mockRestore();

531521

}