























@@ -1117,6 +1117,28 @@ describe("scripts/crabbox-wrapper", () => {
11171117expectGroupedShellCommand(remoteCommand, shellScript);
11181118});
111911191120+it("preserves macOS JS and Git bootstraps for shell-wrapped sparse changed gates", () => {
1121+const shellScript = "bash -lc 'pnpm check:changed'";
1122+const result = runWrapper(
1123+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
1124+["run", "--provider", "aws", "--target", "macos", "--shell", "--", shellScript],
1125+{
1126+gitResponses: {
1127+["config\u0000--bool\u0000core.sparseCheckout"]: { stdout: "true\n" },
1128+["status\u0000--porcelain=v1"]: { stdout: "" },
1129+["merge-base\u0000origin/main\u0000HEAD"]: { stdout: "abc123\n" },
1130+},
1131+},
1132+);
1133+1134+const output = parseFakeCrabboxOutput(result);
1135+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
1136+expect(result.status).toBe(0);
1137+expect(remoteCommand).toContain("git init -q");
1138+expect(remoteCommand).toContain("openclaw_crabbox_bootstrap_macos_js");
1139+expectGroupedShellCommand(remoteCommand, shellScript);
1140+});
1141+11201142it("preserves sparse changed-gate Git bootstrap for assignment-prefix command substitutions", () => {
11211143const shellScript = "TOOL_ROOT=$(pwd) pnpm check:changed";
11221144const result = runWrapper(
@@ -1159,6 +1181,94 @@ describe("scripts/crabbox-wrapper", () => {
11591181expect(remoteCommand).toContain(`&& ${shellScript}`);
11601182});
116111831184+it("preserves sparse changed-gate Git bootstrap for bash -lc shell commands", () => {
1185+const shellScript =
1186+"env CI=1 NODE_OPTIONS=--max-old-space-size=4096 bash -lc 'set -euo pipefail; pnpm check:changed'";
1187+const result = runWrapper(
1188+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
1189+["run", "--provider", "aws", "--shell", "--", shellScript],
1190+{
1191+gitResponses: {
1192+["config\u0000--bool\u0000core.sparseCheckout"]: { stdout: "true\n" },
1193+["status\u0000--porcelain=v1"]: { stdout: "" },
1194+["merge-base\u0000origin/main\u0000HEAD"]: { stdout: "abc123\n" },
1195+},
1196+},
1197+);
1198+1199+const output = parseFakeCrabboxOutput(result);
1200+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
1201+expect(result.status).toBe(0);
1202+expect(remoteCommand).toContain("git init -q");
1203+expect(remoteCommand).toContain(
1204+"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
1205+);
1206+expect(remoteCommand).toContain(`&& ${shellScript}`);
1207+});
1208+1209+it("preserves sparse changed-gate Git bootstrap for shell option values before -c", () => {
1210+const shellScript = "bash -o pipefail -c 'pnpm check:changed'";
1211+const result = runWrapper(
1212+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
1213+["run", "--provider", "aws", "--shell", "--", shellScript],
1214+{
1215+gitResponses: {
1216+["config\u0000--bool\u0000core.sparseCheckout"]: { stdout: "true\n" },
1217+["status\u0000--porcelain=v1"]: { stdout: "" },
1218+["merge-base\u0000origin/main\u0000HEAD"]: { stdout: "abc123\n" },
1219+},
1220+},
1221+);
1222+1223+const output = parseFakeCrabboxOutput(result);
1224+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
1225+expect(result.status).toBe(0);
1226+expect(remoteCommand).toContain("git init -q");
1227+expect(remoteCommand).toContain(`&& ${shellScript}`);
1228+});
1229+1230+it("preserves sparse changed-gate Git bootstrap for attached shell option values before -c", () => {
1231+const shellScript = "bash --rcfile=./ci.bashrc -c 'pnpm check:changed'";
1232+const result = runWrapper(
1233+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
1234+["run", "--provider", "aws", "--shell", "--", shellScript],
1235+{
1236+gitResponses: {
1237+["config\u0000--bool\u0000core.sparseCheckout"]: { stdout: "true\n" },
1238+["status\u0000--porcelain=v1"]: { stdout: "" },
1239+["merge-base\u0000origin/main\u0000HEAD"]: { stdout: "abc123\n" },
1240+},
1241+},
1242+);
1243+1244+const output = parseFakeCrabboxOutput(result);
1245+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
1246+expect(result.status).toBe(0);
1247+expect(remoteCommand).toContain("git init -q");
1248+expect(remoteCommand).toContain(`&& ${shellScript}`);
1249+});
1250+1251+it("preserves sparse changed-gate Git bootstrap for grouped shell options before -c", () => {
1252+const shellScript = "bash -eo pipefail -c 'pnpm check:changed'";
1253+const result = runWrapper(
1254+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
1255+["run", "--provider", "aws", "--shell", "--", shellScript],
1256+{
1257+gitResponses: {
1258+["config\u0000--bool\u0000core.sparseCheckout"]: { stdout: "true\n" },
1259+["status\u0000--porcelain=v1"]: { stdout: "" },
1260+["merge-base\u0000origin/main\u0000HEAD"]: { stdout: "abc123\n" },
1261+},
1262+},
1263+);
1264+1265+const output = parseFakeCrabboxOutput(result);
1266+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
1267+expect(result.status).toBe(0);
1268+expect(remoteCommand).toContain("git init -q");
1269+expect(remoteCommand).toContain(`&& ${shellScript}`);
1270+});
1271+11621272it("preserves sparse changed-gate Git bootstrap for absolute time-prefixed shell commands", () => {
11631273const shellScript = "/usr/bin/time -l pnpm check:changed";
11641274const result = runWrapper(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。