mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Let coverage read take a runner folder so relative lcov paths resolve, and fix Handoff's script path
AI Assisted
This commit is contained in:
1 parent
2cb174ecf0
commit
17f98e62b5
4 files changed
+23
-5
No files matched your search
@@ -168,3 +168,14 @@ test("coverage read: exactly one format flag is required", () => {
|
||||
assert.equal(C(dir, "read", "--lcov", "a", "--go-func", "b").code, 2);
|
||||
assert.equal(C(dir).code, 2);
|
||||
});
|
||||
|
||||
test("coverage read --lcov --cwd: a runner's relative paths get its folder in front", () => {
|
||||
const dir = tmp("cov-cwd");
|
||||
write(dir, "lcov.info", "SF:src/x.ts\nDA:1,1\nLF:1\nLH:1\nend_of_record\nSF:D:/elsewhere/y.ts\nDA:1,0\nLF:1\nLH:0\nend_of_record\n");
|
||||
const r = C(dir, "read", "--lcov", "lcov.info", "--cwd", "./packages/api/");
|
||||
assert.equal(r.code, 0, r.stderr);
|
||||
assert.deepEqual(
|
||||
r.json.files.map((f) => f.file),
|
||||
["D:/elsewhere/y.ts", "packages/api/src/x.ts"]
|
||||
);
|
||||
});
|
||||
@@ -52,7 +52,7 @@ The dashboard lists the handoff for this checkout until it is picked up, and old
|
||||
|
||||
`specs/` is gitignored — Glob/Grep and file search silently skip it. If the
|
||||
conversation worked inside `specs/<feature>/`, confirm the exact state before
|
||||
writing with `node "<S>/specs.mjs" status specs/<feature>`, which reads the disk:
|
||||
writing with `node "<S>/specs.mjs" status specs/<feature>` (`<S>` is `scripts/` beside this SKILL.md: `~/.agents/skills/plan2code-handoff/scripts/` globally), which reads the disk:
|
||||
|
||||
- Which `phase-X.md` is in progress, and which of its tasks are still open
|
||||
(each phase's `tasks` and `openTasks`: checkboxes are ground truth, not the
|
||||
|
||||
@@ -14,7 +14,7 @@ import { EXIT, fail, out, parseArgs, run } from "./common.mjs";
|
||||
const USAGE = `
|
||||
coverage.mjs: per-file coverage from a coverage tool's output. JSON on stdout.
|
||||
|
||||
node coverage.mjs read --lcov <file> [--root <dir>]
|
||||
node coverage.mjs read --lcov <file> [--root <dir>] [--cwd <dir>]
|
||||
node coverage.mjs read --go-func <file> [--root <dir>]
|
||||
Prints { ok, format, files: [{ file, lines, hit, pct }], total },
|
||||
files sorted by path, pct with one decimal.
|
||||
@@ -22,7 +22,9 @@ coverage.mjs: per-file coverage from a coverage tool's output. JSON on stdout.
|
||||
lines is LF (or the DA count when LF is missing), hit is LH
|
||||
(or the DA lines with hits above 0). Paths are made relative
|
||||
to --root (default: the current folder) with forward slashes;
|
||||
an absolute path outside the root is kept as given. total
|
||||
an absolute path outside the root is kept as given. A relative
|
||||
SF: path is relative to the runner's folder: pass it as --cwd
|
||||
(relative to the root) to get project-relative paths. total
|
||||
sums every file.
|
||||
go-func "<import path>/<file>.go:<line>: <func> <pct>%" lines,
|
||||
grouped by file: pct is the mean of the file's functions,
|
||||
@@ -149,7 +151,7 @@ function readGoFunc(text, root) {
|
||||
/* ------------------------------------------------------------------ main */
|
||||
|
||||
async function main(argv) {
|
||||
const args = parseArgs(argv, { values: ["lcov", "go-func", "root"] });
|
||||
const args = parseArgs(argv, { values: ["lcov", "go-func", "root", "cwd"] });
|
||||
const [cmd, ...extra] = args._;
|
||||
if (!cmd) fail(EXIT.USAGE, "missing-command", "A subcommand is required: read.", "Run with --help for usage.");
|
||||
if (cmd !== "read") fail(EXIT.USAGE, "unknown-command", `Unknown subcommand "${cmd}".`, "Use: read.");
|
||||
@@ -166,6 +168,11 @@ async function main(argv) {
|
||||
fail(EXIT.NOT_FOUND, "no-file", `Cannot read ${file}.`, "Run the coverage command first, then pass the file it wrote.");
|
||||
}
|
||||
const read = format === "lcov" ? readLcov(text, root) : readGoFunc(text, root);
|
||||
const prefix = path.posix.normalize(slash(args.cwd || ".")).replace(/\/+$/, "").replace(/^\.$/, "");
|
||||
if (read && format === "lcov" && prefix) {
|
||||
for (const f of read.files) if (!isAbs(f.file)) f.file = path.posix.join(prefix, f.file);
|
||||
read.files.sort(byPath);
|
||||
}
|
||||
if (!read) {
|
||||
fail(
|
||||
EXIT.INVALID,
|
||||
|
||||
@@ -73,7 +73,7 @@ Run `test-match.mjs gaps --scope <branch|path|all>` (with `--path <p>` for a nam
|
||||
|
||||
**Coverage, only when the project already has it.** When `discover` lists a `coverage` entry for a runner in scope, offer it on one card naming the command and what it covers. Never run it without a yes.
|
||||
|
||||
- **Yes:** when `cmd` has an `<out>` placeholder (already quoted), replace just `<out>` with a file in the session folder (`open` printed it; in the terminal, the OS temp folder). Run it with `run-check.mjs` in its `cwd`, with a `--log` file. Then read the output with `coverage.mjs read`, per `reads`: `--lcov <out>` when the command wrote to `<out>`, else `--lcov <cwd>/coverage/lcov.info` (Jest's and Vitest's default); `--go-func <log>` for Go, whose `go tool cover -func` table is printed into the run's log. Files at 0% or under 50% that matching called covered become extra gaps, method `coverage`. A coverage run that fails or times out, or a `coverage.mjs read` that fails (exit 3 or 4, as for .NET's Cobertura output): say so in one line, and matching alone continues.
|
||||
- **Yes:** when `cmd` has an `<out>` placeholder (already quoted), replace just `<out>` with a file in the session folder (`open` printed it; in the terminal, the OS temp folder). Run it with `run-check.mjs` in its `cwd`, with a `--log` file. Then read the output with `coverage.mjs read`, per `reads`: `--lcov <out>` when the command wrote to `<out>`, else `--lcov <cwd>/coverage/lcov.info` (Jest's and Vitest's default), always with `--cwd <the entry's cwd>` so its relative paths line up with the project's; `--go-func <log>` for Go, whose `go tool cover -func` table is printed into the run's log. Files at 0% or under 50% that matching called covered become extra gaps, method `coverage`. A coverage run that fails or times out, or a `coverage.mjs read` that fails (exit 3 or 4, as for .NET's Cobertura output): say so in one line, and matching alone continues.
|
||||
- **No:** matching alone continues, and the plan says coverage was skipped.
|
||||
|
||||
Every gap carries the method that found it (`matching` or `coverage`), ranked as `gaps` ranks them; coverage gaps follow the matching ones, lowest percent first. No gaps at all → say every source file in scope has a test, offer the test map (Step 8) when the run had none, and end.
|
||||
|
||||
Reference in new issue
Block a user