Skip to content

Commit a7cca37

Browse files
authored
fix(testbox): restore claims across path aliases (#119170)
1 parent 0069f3f commit a7cca37

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎scripts/crabbox-wrapper.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
mkdtempSync,
1111
readFileSync,
1212
readdirSync,
13+
realpathSync,
1314
renameSync,
1415
rmSync,
1516
statfsSync,
@@ -3783,7 +3784,9 @@ try {
37833784
const checkout = prepareFullCheckoutForSync({ changedGateBase });
37843785
fullCheckout = checkout;
37853786
normalizedArgs = injectFullCheckoutLeaseReclaim(normalizedArgs);
3786-
childCwd = checkout.dir;
3787+
// Crabbox claims Git's physical top-level. Match it so macOS /var aliases
3788+
// restore to the invoking repository instead of the disposable checkout.
3789+
childCwd = realpathSync(checkout.dir);
37873790
cleanupChildCwd = () => checkout.cleanup();
37883791
remoteChangedGateBase = checkout.changedGateBase;
37893792
remoteChangedGateAlias = changedGate?.remoteAlias ?? "";

‎test/scripts/crabbox-wrapper.test.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import {
77
mkdtempSync,
88
readFileSync,
99
readdirSync,
10+
realpathSync,
1011
rmSync,
1112
statSync,
13+
symlinkSync,
1214
writeFileSync,
1315
} from "node:fs";
1416
import { tmpdir } from "node:os";
@@ -607,7 +609,23 @@ function runSuccessfulMacosScript(script: string, trailingArgs: string[] = []):
607609
}
608610

609611
function runDelegatedBlacksmith(args: string[], env: Record<string, string>) {
610-
return runDefaultWrapper(args, { ...cleanSparseSyncOptions, env });
612+
if (process.platform === "win32") {
613+
return runDefaultWrapper(args, { ...cleanSparseSyncOptions, env });
614+
}
615+
const physicalSyncRoot = mkdtempSync(path.join(tmpdir(), "openclaw-crabbox-sync-physical-"));
616+
const syncRootAlias = `${physicalSyncRoot}-alias`;
617+
symlinkSync(physicalSyncRoot, syncRootAlias, "dir");
618+
tempDirs.push(syncRootAlias, physicalSyncRoot);
619+
const result = runDefaultWrapper(args, {
620+
...cleanSparseSyncOptions,
621+
env: { ...env, OPENCLAW_CRABBOX_SYNC_TMPDIR: syncRootAlias },
622+
});
623+
if (result.stdout.trim()) {
624+
expect(
625+
parseFakeCrabboxOutput(result).cwd.startsWith(`${realpathSync(physicalSyncRoot)}${path.sep}`),
626+
).toBe(true);
627+
}
628+
return result;
611629
}
612630

613631
const remoteChangedGateEnvPrefix =

0 commit comments

Comments
 (0)