Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/rees-coverage-chdir.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Preloaded via --require before node:test loads review-enrichment's test files.
// c8 (the parent process) must keep its own cwd at the monorepo root so lcov SF: paths
// remap to `review-enrichment/src/**` for Codecov (#6250); this only chdir's the spawned
// test child, so tests that read fixtures with bare relative paths (e.g. "analyzer-metadata.json")
// resolve them against review-enrichment/, matching `npm run test:node`.
const { join } = require("node:path");

process.chdir(join(__dirname, "..", "review-enrichment"));
8 changes: 6 additions & 2 deletions scripts/rees-coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// (not bare `src/**`), and expands the test list in-process so Windows/npm quoting cannot drop the suite.
import { spawnSync } from "node:child_process";
import { readFileSync, readdirSync, writeFileSync } from "node:fs";
import { join, relative } from "node:path";
import { join } from "node:path";
import { fileURLToPath, URL } from "node:url";

/** Normalize c8's SF: paths to forward slashes for Codecov. Swallows only a missing report
Expand Down Expand Up @@ -39,8 +39,10 @@ function main() {
const c8Bin = join(root, "review-enrichment", "node_modules", "c8", "bin", "c8.js");
const reportDir = join(root, "review-enrichment", "coverage");
const testRoot = join(root, "review-enrichment", "test");
const chdirPreload = join(root, "scripts", "rees-coverage-chdir.cjs");

const tests = collectTests(testRoot).map((path) => relative(root, path).split("\\").join("/"));
// Absolute paths: the test child's cwd is review-enrichment/ (see chdirPreload), not root.
const tests = collectTests(testRoot).map((path) => path.split("\\").join("/"));
if (tests.length === 0) {
console.error("rees-coverage: no review-enrichment/test/**/*.test.ts files found");
process.exit(1);
Expand All @@ -57,6 +59,8 @@ function main() {
"--exclude=**/*.d.ts",
"--all",
process.execPath,
"--require",
chdirPreload,
"--test",
"--experimental-strip-types",
...tests,
Expand Down