27 test files matched no vitest config, so they never ran in CI and gave false coverage confidence (the drift the audit flagged). - Re-homed 10 functional suites into the gate (renamed to *.unit.test.ts / *.integration.test.ts): Transaction + TransactionManager, type-utils, integrations/core + odata, comprehensive/public-api-complete, regression (metadata-index-cleanup + v5.7.0-deadlock), vfs/tree-operations + vfs-bulkwrite-race. ~192 previously-dark tests now run and pass. - Deleted 8 bit-rotted/redundant files that fail against 8.0 and never ran: one had a literal syntax error; one used filesystem writer-locks that polluted parallel runs; the rest assert old "Brainy 3.0/v3.0" APIs already covered by the live suites (api/batch-operations + crud-operations-enhanced, brainy-3, comprehensive/core-api + find-triple-intelligence, streaming-pipeline, vfs/vfs-relationships, transaction/integration/typeaware-transactions). - Added a coverage guard (tests/unit/test-suite-coverage-guard.test.ts) that FAILS CI if any *.test.ts ever again falls outside every config, with an explicit, conscious MANUAL_ONLY allowlist for the 9 genuine benchmark / perf / model-load files that are run by hand. Gate green: unit 1712, integration 607. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
69 lines
2.9 KiB
TypeScript
69 lines
2.9 KiB
TypeScript
/**
|
|
* @module tests/unit/test-suite-coverage-guard
|
|
* @description Prevents a test file from silently falling outside EVERY vitest
|
|
* config (so it never runs and gives false coverage confidence — the exact drift
|
|
* that left ~27 test files un-run before 8.0). Every `*.test.ts` must either match
|
|
* a gate config (`tests/unit/**`, `tests/integration/**`, `*.unit.test.ts`,
|
|
* `*.integration.test.ts`) or be explicitly listed in MANUAL_ONLY below.
|
|
*/
|
|
import { describe, it, expect } from 'vitest'
|
|
import { readdirSync } from 'node:fs'
|
|
import { join, relative, dirname } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '../..')
|
|
const testsDir = join(repoRoot, 'tests')
|
|
|
|
function allTestFiles(dir: string, out: string[] = []): string[] {
|
|
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
const p = join(dir, e.name)
|
|
if (e.isDirectory()) allTestFiles(p, out)
|
|
else if (e.isFile() && p.endsWith('.test.ts')) out.push(relative(repoRoot, p).split('\\').join('/'))
|
|
}
|
|
return out
|
|
}
|
|
|
|
/**
|
|
* Test files INTENTIONALLY excluded from the unit/integration gate: benchmarks,
|
|
* scale/perf measurements, package-size checks, and real-model-load checks. They
|
|
* are run manually (slow / need real resources), not in CI. Every entry is a
|
|
* conscious decision — a NEW orphan not listed here fails the guard below.
|
|
*/
|
|
const MANUAL_ONLY = new Set<string>([
|
|
'tests/api/performance-benchmarks.test.ts',
|
|
'tests/critical-neural-validation.test.ts',
|
|
'tests/critical-performance-benchmark.test.ts',
|
|
'tests/model-loading.test.ts',
|
|
'tests/package-size-breakdown.test.ts',
|
|
'tests/package-size-limit.test.ts',
|
|
'tests/performance/graph-scale-performance.test.ts',
|
|
'tests/performance/triple-intelligence-scale.test.ts',
|
|
'tests/performance/typeAware.bench.test.ts'
|
|
])
|
|
|
|
function inGate(rel: string): boolean {
|
|
return (
|
|
rel.startsWith('tests/unit/') ||
|
|
rel.startsWith('tests/integration/') ||
|
|
rel.endsWith('.unit.test.ts') ||
|
|
rel.endsWith('.integration.test.ts')
|
|
)
|
|
}
|
|
|
|
describe('test-suite coverage guard', () => {
|
|
it('every *.test.ts runs in a gate config or is explicitly allowlisted as manual', () => {
|
|
const orphans = allTestFiles(testsDir).filter((f) => !inGate(f) && !MANUAL_ONLY.has(f))
|
|
expect(
|
|
orphans,
|
|
'These test files match NO vitest config and are not in MANUAL_ONLY — rename to ' +
|
|
'*.unit.test.ts / *.integration.test.ts (or move under tests/unit|integration), or add to ' +
|
|
`MANUAL_ONLY if they are benchmarks:\n${orphans.join('\n')}`
|
|
).toEqual([])
|
|
})
|
|
|
|
it('the manual allowlist has no stale entries (every listed file still exists)', () => {
|
|
const all = new Set(allTestFiles(testsDir))
|
|
const stale = [...MANUAL_ONLY].filter((f) => !all.has(f))
|
|
expect(stale, `MANUAL_ONLY lists files that no longer exist — remove them:\n${stale.join('\n')}`).toEqual([])
|
|
})
|
|
})
|