test(fs-sandbox): keep Windows coverage portable
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user