mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* refactor(tooling): organize test runtime and maintenance owners * test(tooling): preserve relocated runtime fixture dependency edges * refactor(tooling): preserve xterm routing owner checks * ci(tooling): include routing owner in sparse checkout * test(tooling): preserve copied workflow dependency closures * fix(tooling): normalize hashed JSON assets in release parity * fix(tooling): distinguish asset aliases from literal references * fix(tooling): frame normalized asset reference payloads * fix(tooling): normalize decoded JSON asset references * refactor(tooling): organize build, CI and release owners * fix(tooling): align moved generator and workflow path contracts * fix(tooling): update generated plugin bundle owner banners * test(tooling): create relocated mobile verifier fixture directories * test(tooling): copy headless detector dependency closure * test(tooling): align native batch policy fixtures with owner path * fix(tooling): link moved reliability command to historical evidence * fix(tooling): preserve nested sandbox owners and canonical guide source * fix(tooling): target release version owners in checkout fixture
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
import { mkdir, mkdtemp, readdir, rm, utimes } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { afterEach, expect, it } from 'vitest'
|
|
import { reclaimVitestModuleCaches } from './reclaim-vitest-module-caches.mjs'
|
|
import { localModuleCacheParent } from '../test-runtime/module-cache/vitest-local-module-cache.mjs'
|
|
|
|
const roots = []
|
|
const nowMs = Date.now()
|
|
|
|
afterEach(async () => {
|
|
for (const root of roots.splice(0)) {
|
|
await rm(root, { recursive: true, force: true })
|
|
}
|
|
})
|
|
|
|
async function worktreeWithCaches(ages) {
|
|
const worktree = await mkdtemp(join(tmpdir(), 'orca-vitest-module-cache-'))
|
|
roots.push(worktree)
|
|
for (const [name, days] of Object.entries(ages)) {
|
|
const path = join(localModuleCacheParent(worktree), name)
|
|
await mkdir(path, { recursive: true })
|
|
const time = new Date(nowMs - days * 86_400_000)
|
|
await utimes(path, time, time)
|
|
}
|
|
return worktree
|
|
}
|
|
|
|
it('removes only caches idle past the cutoff, and only with --apply', async () => {
|
|
const worktree = await worktreeWithCaches({ idle: 8, recent: 1 })
|
|
const options = { worktrees: [worktree], nowMs, report: () => {} }
|
|
|
|
expect(await reclaimVitestModuleCaches(options)).toEqual({ entries: 1 })
|
|
expect((await readdir(localModuleCacheParent(worktree))).sort()).toEqual(['idle', 'recent'])
|
|
|
|
await reclaimVitestModuleCaches({ ...options, apply: true })
|
|
expect(await readdir(localModuleCacheParent(worktree))).toEqual(['recent'])
|
|
})
|
|
|
|
it('skips the excluded worktree', async () => {
|
|
const worktree = await worktreeWithCaches({ idle: 8 })
|
|
await reclaimVitestModuleCaches({
|
|
worktrees: [worktree],
|
|
excludeWorktree: worktree,
|
|
apply: true,
|
|
nowMs,
|
|
report: () => {}
|
|
})
|
|
expect(await readdir(localModuleCacheParent(worktree))).toEqual(['idle'])
|
|
})
|