diff --git a/scripts/test-report.ts b/scripts/test-report.ts index 685f4e9..e90e7a6 100644 --- a/scripts/test-report.ts +++ b/scripts/test-report.ts @@ -1,5 +1,7 @@ -// Runs the whole test suite once and renders reports/test-report.md: a summary, -// a describe-grouped inventory, and a coverage table. +// Runs the test suite and renders reports/test-report.md: a summary, a +// describe-grouped inventory, and a coverage table. +// Any positional arguments are forwarded to `bun test` as path filters; with +// none, the whole repo runs. // The report is written even when tests fail, and the process exits with the // test run's own status so CI can gate on it. // Split into run -> parse -> render so a future CI job can reuse parse+render @@ -44,12 +46,13 @@ interface FileCoverage { // --- run --- -function runTests(): number { +function runTests(paths: string[]): number { mkdirSync(REPORTS_DIR, { recursive: true }); const proc = Bun.spawnSync( [ "bun", "test", + ...paths, "--coverage", "--coverage-reporter=lcov", "--reporter=junit", @@ -254,10 +257,12 @@ function gitSha(): string { return proc.exitCode === 0 ? proc.stdout.toString().trim() : "unknown"; } -const exitCode = runTests(); +const paths = process.argv.slice(2); +const exitCode = runTests(paths); mkdirSync(REPORTS_DIR, { recursive: true }); -const meta = `Generated ${new Date().toISOString()} · commit ${gitSha()} · whole repo`; +const scope = paths.length > 0 ? paths.join(", ") : "whole repo"; +const meta = `Generated ${new Date().toISOString()} · commit ${gitSha()} · ${scope}`; if (!existsSync(JUNIT_PATH)) { writeFileSync(