Просмотр исходного кода

test(spill-local): cover platform-specific cleanup paths

Dudu-0223 1 месяц назад
Родитель
Сommit
97693bbc85

+ 6 - 0
packages/spill/spill-local/src/cleanup.ts

@@ -66,6 +66,8 @@ function rootIdentity(path: string, stats: Stats): string {
 async function hasProtectedAncestors(path: string): Promise<boolean> {
   /* v8 ignore next -- POSIX ancestry checks have no Windows ACL equivalent. */
   if (process.platform === 'win32' || process.geteuid === undefined) return true
+  /* v8 ignore start -- Windows takes the return above; POSIX tests exercise
+     the ancestor ownership and mode policy. */
   const currentUid = process.geteuid()
   let child = path
   let childStats = await lstat(child)
@@ -84,6 +86,7 @@ async function hasProtectedAncestors(path: string): Promise<boolean> {
     child = parent
     childStats = stats
   }
+  /* v8 ignore stop */
 }
 
 /**
@@ -136,10 +139,13 @@ async function resolveRoot(path: string, allowSymlink: boolean, warn: WarnFn): P
     return undefined
     /* v8 ignore stop */
   }
+  /* v8 ignore start -- Windows has no POSIX ownership or mode rejection path;
+     POSIX tests exercise both unsafe-directory conditions. */
   if (!isTrustedDirectory(stats) || !protectedAncestors) {
     warnSafely(warn, `spill-local: skipped unsafe root ${canonical}: expected a current-user-owned directory with protected write and ancestor permissions`)
     return undefined
   }
+  /* v8 ignore stop */
   return { path: canonical, identity: rootIdentity(canonical, stats) }
 }
 

+ 4 - 0
packages/spill/spill-local/tests/spill-local.spec.ts

@@ -477,6 +477,10 @@ describe('startup cleanup sweep', () => {
     }
   })
 
+  it('omits a missing active root', async () => {
+    expect(await gatherSweepRoots(join(root, 'missing'), () => {}, root)).toEqual([])
+  })
+
   it('skips a root that another POSIX user could replace', async () => {
     if (process.platform === 'win32') return
     const unsafeParent = join(root, 'unsafe-parent')