cc-haha/scripts/pr/bun-test-filter.ts
程序员阿江(Relakkes) 08dd64596a fix(ci): root explicit Bun test filters
Avoid Bun filter-mode repository scans that exhaust macOS file descriptors and corrupt subprocess test evidence. Apply rooted filters across server, contract, coverage, persistence, policy, desktop native, and adapter test entrypoints.

Confidence: high

Scope-risk: narrow

Tested: bun run check:policy; bun run check:server; bun run check:chat-contract
2026-07-10 23:49:46 +08:00

21 lines
583 B
TypeScript

import { isAbsolute } from 'node:path'
const WINDOWS_ABSOLUTE_PATH = /^(?:[a-zA-Z]:[\\/]|\\\\)/
/**
* Root explicit Bun test filters so Bun does not scan the whole repository.
* Unrooted filters can retain enough directory descriptors on macOS to break
* subprocess output capture: https://github.com/oven-sh/bun/issues/32067
*/
export function rootBunTestFilter(filter: string): string {
if (
filter.startsWith('./') ||
filter.startsWith('../') ||
isAbsolute(filter) ||
WINDOWS_ABSOLUTE_PATH.test(filter)
) {
return filter
}
return `./${filter}`
}