Skip to content

Commit abf75e1

Browse files
XuZehan-iCenterXuZehan-iCenter
authored andcommitted
fix(test): exclude browser cache dirs from copyDirIfExists in live test staging
used with no filter, blindly copying multi-GB browser cache/profile/recording directories (e.g. from .antigravity-browser-profile) into temp test homes, causing ENOSPC. Add a segment-based exclusion set that skips Cache, Cache_Data, GPUCache, browser_recordings, antigravity-browser-profile, and CacheStorage directories while preserving auth files like .gemini/auth.json. Fixes #91893
1 parent 69aca06 commit abf75e1

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

‎test/test-env.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,48 @@ describe("installTestEnv", () => {
251251
expect(process.env.TEST_PROFILE_ONLY).toBeUndefined();
252252
});
253253

254+
it("excludes browser cache and recording directories during live test staging", () => {
255+
const realHome = createTempHome();
256+
257+
// Auth file that should be copied
258+
writeFile(path.join(realHome, ".gemini", "auth.json"), '{"key":"value"}\n');
259+
260+
// Cache directories that should be excluded
261+
const cacheDirs = [
262+
path.join(realHome, ".gemini", "antigravity-browser-profile", "Default", "Cache", "Cache_Data", "data_0"),
263+
path.join(realHome, ".gemini", "antigravity-browser-profile", "Default", "GPUCache", "index"),
264+
path.join(realHome, ".gemini", "antigravity", "browser_recordings", "session.json"),
265+
path.join(realHome, ".gemini", "Service Worker", "CacheStorage", "index"),
266+
];
267+
for (const cacheFile of cacheDirs) {
268+
writeFile(cacheFile, "cache-data");
269+
}
270+
271+
process.env.HOME = realHome;
272+
process.env.USERPROFILE = realHome;
273+
process.env.OPENCLAW_LIVE_TEST = "1";
274+
process.env.OPENCLAW_LIVE_TEST_QUIET = "1";
275+
276+
const testEnv = installTestEnv();
277+
cleanupFns.push(testEnv.cleanup);
278+
279+
// Auth file should be copied
280+
expect(
281+
fs.existsSync(path.join(testEnv.tempHome, ".gemini", "auth.json")),
282+
).toBe(true);
283+
284+
// Cache directories should NOT be copied
285+
expect(
286+
fs.existsSync(path.join(testEnv.tempHome, ".gemini", "antigravity-browser-profile")),
287+
).toBe(false);
288+
expect(
289+
fs.existsSync(path.join(testEnv.tempHome, ".gemini", "antigravity", "browser_recordings")),
290+
).toBe(false);
291+
expect(
292+
fs.existsSync(path.join(testEnv.tempHome, ".gemini", "Service Worker", "CacheStorage")),
293+
).toBe(false);
294+
});
295+
254296
it("falls back to parsing ~/.profile when bash is unavailable", async () => {
255297
const realHome = createTempHome();
256298
writeFile(path.join(realHome, ".profile"), "export TEST_PROFILE_ONLY=from-profile\n");

‎test/test-env.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ function ensureParentDir(targetPath: string): void {
249249
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
250250
}
251251

252+
const COPY_EXCLUDE_SEGMENTS = new Set([
253+
"Cache",
254+
"Cache_Data",
255+
"GPUCache",
256+
"browser_recordings",
257+
"antigravity-browser-profile",
258+
"CacheStorage",
259+
]);
260+
252261
function copyDirIfExists(sourcePath: string, targetPath: string): void {
253262
if (!fs.existsSync(sourcePath)) {
254263
return;
@@ -257,6 +266,10 @@ function copyDirIfExists(sourcePath: string, targetPath: string): void {
257266
fs.cpSync(sourcePath, targetPath, {
258267
recursive: true,
259268
force: true,
269+
filter: (src) => {
270+
const segments = src.split(path.sep);
271+
return !segments.some((seg) => COPY_EXCLUDE_SEGMENTS.has(seg));
272+
},
260273
});
261274
}
262275

0 commit comments

Comments
 (0)