test(fs-sandbox): keep Windows coverage portable

This commit is contained in:
Tianyi Cui
2026-07-20 21:20:55 +08:00
parent 23379de629
commit 7239513b98
2 changed files with 4 additions and 1 deletions

View File

@@ -9,9 +9,11 @@ import type { BigIntStats } from 'node:fs'
import { stat } from 'node:fs/promises'
import { dirname, sep } from 'node:path'
const MISSING_CODES: ReadonlySet<NodeJS.ErrnoException['code']> = new Set(['ENOENT', 'ENOTDIR'])
function isMissing(error: unknown): boolean {
const code = (error as NodeJS.ErrnoException).code
return code === 'ENOENT' || code === 'ENOTDIR'
return MISSING_CODES.has(code)
}
function comparablePath(path: string, caseSensitive: boolean): string {

View File

@@ -27,6 +27,7 @@ describe('filesystem sandbox containment', () => {
it('uses case-insensitive lexical comparison for Windows-style containment', async () => {
expect(await isPathUnder(join(base.toUpperCase(), 'child'), base.toLowerCase(), false)).toBe(true)
expect(await isPathUnder(join(base, 'case-sensitive-child'), base, true)).toBe(true)
})
it('recognizes an alias-equivalent root by filesystem identity for a missing target', async () => {