Files
orca/config/scripts/vitest-sqlite-runtime-cache.test.ts
T
Neil e4bbbe045f perf(test): faster local test loop and cold-worktree changed runs (#33421)
- test:changed exits before starting Vitest when Git reports no changed files.
- Unrecorded tests beyond 100 in scope use Vitest's static import graph instead
  of all running, so a fresh worktree's first changed run no longer runs the
  whole suite (patched RecordedModulesResolver; CI does not record, unchanged).
- Bun's slow config load was the SQLite import scan statting every unit test;
  filtered runs now classify only the tests their filters can select, and the
  scan walks directories instead of fs.globSync.
- Silence the native config loader notice on every run.
- Zod's test bundle is content-addressed and reused, so a killed run leaks
  nothing; leaked per-run directories older than 6h are swept.
- build:packages skips compiling when package inputs, compiler, and dist are
  unchanged; test scripts no longer nest pnpm invocations.
2026-10-24 23:15:51 -07:00

43 lines
1.6 KiB
TypeScript

import { createHash } from 'node:crypto'
import type * as FileSystem from 'node:fs'
import { readFileSync } from 'node:fs'
import { expect, it, vi } from 'vitest'
it('re-derives SQLite assignments from malformed disposable cache data', async () => {
const version = createHash('sha256')
.update(readFileSync(new URL('./vitest-sqlite-runtime-scan.mjs', import.meta.url)))
.digest('hex')
for (const files of [null, { 'src/fixture.test.ts': [1, 2, 'false'] }]) {
for (const [source, expected] of [
['export {}', []],
["import './main/sqlite/sync-database'", ['src/fixture.test.ts']]
] as const) {
vi.doMock('node:fs', async (original) => ({
...(await original<typeof FileSystem>()),
readdirSync: (path: string) =>
String(path).endsWith('src')
? [{ name: 'fixture.test.ts', isDirectory: () => false }]
: [],
statSync: () => ({ mtimeMs: 1, size: 2 }),
readFileSync: (path: Parameters<typeof readFileSync>[0]) =>
String(path).endsWith('.json')
? JSON.stringify({ version, files })
: String(path).endsWith('fixture.test.ts')
? source
: readFileSync(path),
mkdirSync: vi.fn(),
writeFileSync: vi.fn(),
renameSync: vi.fn()
}))
vi.resetModules()
try {
const { findSqliteRuntimeTests } = await import('./vitest-sqlite-runtime-scan.mjs')
expect(findSqliteRuntimeTests()).toEqual(expected)
} finally {
vi.doUnmock('node:fs')
vi.resetModules()
}
}
}
})