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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
Blog — PlanetScale
Blog — PlanetScale
F
Fortinet All Blogs
腾讯CDC
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
WordPress大学
WordPress大学
雷峰网
雷峰网
小众软件
小众软件
D
DataBreaches.Net
V
Visual Studio Blog
博客园 - Franky
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
博客园 - 聂微东
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
云风的 BLOG
云风的 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: speed up crabbox wrapper tests · openclaw/openclaw@...
steipete · 2026-05-27 · via Recent Commits to openclaw:main

@@ -6,35 +6,24 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest";

6677

const tempDirs: string[] = [];

88

const repoRoot = process.cwd();

9+

const fakeCrabboxBinDirs = new Map<string, string>();

9101011

function makeFakeCrabbox(helpText: string): string {

12+

const cached = fakeCrabboxBinDirs.get(helpText);

13+

if (cached) {

14+

return cached;

15+

}

1116

const binDir = mkdtempSync(path.join(tmpdir(), "openclaw-fake-crabbox-"));

1217

tempDirs.push(binDir);

1318

writeFakeCrabbox(binDir, helpText);

19+

fakeCrabboxBinDirs.set(helpText, binDir);

1420

return binDir;

1521

}

16221723

function writeFakeCrabbox(binDir: string, helpText: string): string {

1824

mkdirSync(binDir, { recursive: true });

1925

const crabboxPath = path.join(binDir, "crabbox");

2026

const helperPath = path.join(binDir, "fake-crabbox-json.cjs");

21-

const helperScript = [

22-

"const args = process.argv.slice(2);",

23-

'if (args[0] === "config" && args[1] === "show" && args.includes("--json")) {',

24-

" const status = Number.parseInt(process.env.OPENCLAW_FAKE_CRABBOX_CONFIG_STATUS || '0', 10);",

25-

" if (status !== 0) {",

26-

" process.stderr.write('config unavailable\\n');",

27-

" process.exit(status);",

28-

" }",

29-

' process.stdout.write(process.env.OPENCLAW_FAKE_CRABBOX_CONFIG_JSON || \'{"coordinator":"configured-broker","brokerAuth":"configured"}\');',

30-

" process.exit(0);",

31-

"}",

32-

"const scriptIndex = args.findIndex((arg) => arg === '--script' || arg === '-script');",

33-

"const scriptPath = scriptIndex >= 0 ? args[scriptIndex + 1] : '';",

34-

"const scriptContent = scriptPath ? require('node:fs').readFileSync(scriptPath, 'utf8') : '';",

35-

"console.log(JSON.stringify({ args, cwd: process.cwd(), scriptContent }));",

36-

].join("\n");

37-

writeFileSync(helperPath, `${helperScript}\n`, "utf8");

38273928

if (process.platform !== "win32") {

4029

const script = [

@@ -64,13 +53,48 @@ function writeFakeCrabbox(binDir: string, helpText: string): string {

6453

" fi",

6554

" done",

6655

"fi",

67-

`exec ${shellSingleQuote(process.execPath)} ${shellSingleQuote(helperPath)} "$@"`,

56+

'script_path=""',

57+

'previous_arg=""',

58+

'for arg in "$@"; do',

59+

' if [ "$previous_arg" = "--script" ] || [ "$previous_arg" = "-script" ]; then',

60+

' script_path="$arg"',

61+

" break",

62+

" fi",

63+

' previous_arg="$arg"',

64+

"done",

65+

'printf "%s\\0" "__OPENCLAW_FAKE_CRABBOX_V1__"',

66+

'printf "%s\\0" "$PWD"',

67+

'printf "%s\\0" "$#"',

68+

'for arg in "$@"; do',

69+

' printf "%s\\0" "$arg"',

70+

"done",

71+

'if [ -n "$script_path" ] && [ -f "$script_path" ]; then',

72+

' cat "$script_path"',

73+

"fi",

6874

].join("\n");

6975

writeFileSync(crabboxPath, `${script}\n`, "utf8");

7076

chmodSync(crabboxPath, 0o755);

7177

return crabboxPath;

7278

}

737980+

const helperScript = [

81+

"const args = process.argv.slice(2);",

82+

'if (args[0] === "config" && args[1] === "show" && args.includes("--json")) {',

83+

" const status = Number.parseInt(process.env.OPENCLAW_FAKE_CRABBOX_CONFIG_STATUS || '0', 10);",

84+

" if (status !== 0) {",

85+

" process.stderr.write('config unavailable\\n');",

86+

" process.exit(status);",

87+

" }",

88+

' process.stdout.write(process.env.OPENCLAW_FAKE_CRABBOX_CONFIG_JSON || \'{"coordinator":"configured-broker","brokerAuth":"configured"}\');',

89+

" process.exit(0);",

90+

"}",

91+

"const scriptIndex = args.findIndex((arg) => arg === '--script' || arg === '-script');",

92+

"const scriptPath = scriptIndex >= 0 ? args[scriptIndex + 1] : '';",

93+

"const scriptContent = scriptPath ? require('node:fs').readFileSync(scriptPath, 'utf8') : '';",

94+

"console.log(JSON.stringify({ args, cwd: process.cwd(), scriptContent }));",

95+

].join("\n");

96+

writeFileSync(helperPath, `${helperScript}\n`, "utf8");

97+7498

const script = [

7599

"#!/usr/bin/env node",

76100

"const args = process.argv.slice(2);",

@@ -104,6 +128,39 @@ function makeFakeGit(

104128

const binDir = mkdtempSync(path.join(tmpdir(), "openclaw-fake-git-"));

105129

tempDirs.push(binDir);

106130

const gitPath = path.join(binDir, "git");

131+

if (process.platform !== "win32") {

132+

const script = [

133+

"#!/bin/sh",

134+

'if [ "$1" = "worktree" ] && [ "$2" = "add" ]; then',

135+

' mkdir -p "$4"',

136+

" exit 0",

137+

"fi",

138+

'if [ "$1" = "-C" ] && [ "$3" = "sparse-checkout" ] && [ "$4" = "disable" ]; then',

139+

" exit 0",

140+

"fi",

141+

'if [ "$1" = "-C" ] && [ "$3" = "reset" ] && [ "$4" = "--mixed" ]; then',

142+

" exit 0",

143+

"fi",

144+

'if [ "$1" = "worktree" ] && [ "$2" = "remove" ]; then',

145+

" exit 0",

146+

"fi",

147+

...Object.entries(responses).flatMap(([key, response]) => {

148+

const args = key.split("\u0000");

149+

return [

150+

`if ${shellArgListCondition(args)}; then`,

151+

response.stdout ? ` printf "%s" ${shellSingleQuote(response.stdout)}` : "",

152+

response.stderr ? ` printf "%s" ${shellSingleQuote(response.stderr)} >&2` : "",

153+

` exit ${response.status ?? 0}`,

154+

"fi",

155+

].filter(Boolean);

156+

}),

157+

"exit 1",

158+

].join("\n");

159+

writeFileSync(gitPath, `${script}\n`, "utf8");

160+

chmodSync(gitPath, 0o755);

161+

return binDir;

162+

}

163+107164

const script = [

108165

"#!/usr/bin/env node",

109166

"const fs = require('node:fs');",

@@ -126,6 +183,14 @@ function makeFakeGit(

126183

return binDir;

127184

}

128185186+

function shellArgListCondition(args: string[]): string {

187+

const checks = [`[ "$#" -eq ${args.length} ]`];

188+

for (const [index, arg] of args.entries()) {

189+

checks.push(`[ "$${index + 1}" = ${shellSingleQuote(arg)} ]`);

190+

}

191+

return checks.join(" && ");

192+

}

193+129194

function runWrapper(

130195

helpText: string,

131196

args: string[],

@@ -170,6 +235,24 @@ function parseFakeCrabboxOutput(result: ReturnType<typeof runWrapper>): {

170235

cwd: string;

171236

scriptContent?: string;

172237

} {

238+

const marker = "__OPENCLAW_FAKE_CRABBOX_V1__\0";

239+

if (result.stdout.startsWith(marker)) {

240+

let offset = marker.length;

241+

const readField = () => {

242+

const end = result.stdout.indexOf("\0", offset);

243+

if (end < 0) {

244+

throw new Error("missing fake Crabbox output field terminator");

245+

}

246+

const value = result.stdout.slice(offset, end);

247+

offset = end + 1;

248+

return value;

249+

};

250+

const cwd = readField();

251+

const argCount = Number.parseInt(readField(), 10);

252+

const args = Array.from({ length: argCount }, () => readField());

253+

const scriptContent = result.stdout.slice(offset);

254+

return { args, cwd, scriptContent };

255+

}

173256

return JSON.parse(result.stdout.trim()) as {

174257

args: string[];

175258

cwd: string;

@@ -231,7 +314,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {

231314

);

232315233316

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

234-

expect(result.stdout).toContain('"local-container"');

317+

expect(parseFakeCrabboxOutput(result).args).toContain("local-container");

235318

});

236319237320

it("defaults AWS macOS runs to on-demand capacity", () => {

@@ -1238,7 +1321,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {

12381321

);

1239132212401323

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

1241-

expect(result.stdout).toContain('"docker"');

1324+

expect(parseFakeCrabboxOutput(result).args).toContain("docker");

12421325

expect(result.stderr).toContain(

12431326

"providers=hetzner,aws,local-container,blacksmith-testbox,docker,cloudflare",

12441327

);

@@ -1297,7 +1380,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {

12971380

]);

1298138112991382

expect(result.status, alias).toBe(0);

1300-

expect(result.stdout).toContain(`"${alias}"`);

1383+

expect(parseFakeCrabboxOutput(result).args).toContain(alias);

13011384

},

13021385

);

13031386

@@ -1312,7 +1395,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {

13121395

const result = runWrapper(helpText, ["run", "--provider", provider, "--", "echo ok"]);

1313139613141397

expect(result.status, provider).toBe(0);

1315-

expect(result.stdout).toContain(`"${provider}"`);

1398+

expect(parseFakeCrabboxOutput(result).args).toContain(provider);

13161399

}

13171400

});

13181401

@@ -1361,7 +1444,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {

13611444

);

1362144513631446

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

1364-

expect(result.stdout).not.toContain('"--no-sync"');

1447+

expect(parseFakeCrabboxOutput(result).args).not.toContain("--no-sync");

13651448

expect(result.stderr).toContain("syncing from temporary full checkout");

13661449

expect(parseFakeCrabboxOutput(result).cwd).toContain("openclaw-crabbox-sync-");

13671450

});

@@ -1971,7 +2054,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {

19712054

);

1972205519732056

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

1974-

expect(result.stdout).not.toContain('"--no-sync"');

2057+

expect(parseFakeCrabboxOutput(result).args).not.toContain("--no-sync");

19752058

expect(result.stderr).toContain("syncing from temporary full checkout");

19762059

expect(parseFakeCrabboxOutput(result).cwd).toContain("openclaw-crabbox-sync-");

19772060

});