test(windows): make native coverage fixtures portable

This commit is contained in:
Tianyi Cui
2026-08-08 20:36:31 +08:00
parent 85e9f3b7cb
commit f96be1db13
6 changed files with 47 additions and 16 deletions

View File

@@ -62,6 +62,17 @@ async function expectFlushError(promise: Promise<unknown>, message: RegExp): Pro
throw new Error('expected flush to reject')
}
async function expectFlushCode(promise: Promise<unknown>, codes: readonly string[]): Promise<void> {
try {
await promise
} catch (error) {
expect(error).toBeInstanceOf(Error)
expect(codes).toContain((error as NodeJS.ErrnoException).code)
return
}
throw new Error('expected flush to reject')
}
async function freshRoot(): Promise<string> {
const dir = await mkdtemp(join(tmpdir(), 'dsh-jsonl-'))
dirs.push(dir)
@@ -1343,7 +1354,7 @@ describe('SessionPersistenceJsonl: edge cases', () => {
s = inner.sessions.create(SessionId('exists-fault'), { meta: { cwd } })
appendClosedTurn(s)
}, { inject: ['sessions'] }))
await expect(ctx2.sessions.flush(s)).rejects.toThrow(/EEXIST|ENOTDIR/)
await expectFlushCode(ctx2.sessions.flush(s), ['EEXIST', 'ENOTDIR'])
await ctx2.fiber.dispose()
})