feat: scope test report to given paths, default all (task 0003)
Forward any positional arguments to `bun test` as path filters, so `bun run test:report packages/core` reports just core while a bare `bun run test:report` still covers the whole repo. The report's header records the scope.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user