Skip to content

test(coverage-report): cover main()'s three unexecuted CLI paths - #719

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-coverage-report-cli
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-coverage-report-cli

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds tests/coverage-report-cli.test.mjs, covering the three paths in main() of tests/tools/coverage-report.mjs that no test executed.

tests/coverage-report.test.mjs already drives the reporter as a subprocess, but its runReporter helper deletes NODE_V8_COVERAGE from the child environment, so nothing the reporter process does is recorded — only paths with an exit code of their own can be asserted on. The helper here keeps NODE_V8_COVERAGE and deletes only NODE_TEST_CONTEXT. That is safe: the reporter always overrides NODE_V8_COVERAGE for the node --test run it spawns, so the grandchild still writes to its own directory and the counts merged into the suite come only from the reporter itself.

What the three tests pin

  • a bare test path given without a -- separator is passed through to node --test rather than read as a flag, and narrows the run to exactly that one suite
  • a suite importing a JSON module produces the Not reported (N) notice — the only signal that a file's coverage was recorded against loader-generated text and is missing from the table — and the count in the notice matches the files it lists
  • a run whose spawned suite fails exits 1, prints Tests failed; coverage above is reported for context., still renders the table, and does not report a --check failure, proving the suite failure takes precedence over the gates

The failing fixture is written under os.tmpdir() and removed in a finally, so it can never be picked up by a normal node --test run.

Scope

Files: tests/coverage-report-cli.test.mjs (new, only file touched).
Functions: main() and parseArgs() in tests/tools/coverage-report.mjs, lines 76-78, 570-578, 580-583.

Deliberately disjoint from the open region-coverage PRs: collect()'s merge and record-skip paths (437-438, 447-448, 470-473) belong to #702, and the tryRemapJsx/decodeMappings JSX-remap regions (409-410 and others) are claimed by no PR and are left for a separate change.

Verification

TZ=UTC node --test tests/coverage-report-cli.test.mjs   # 3 pass
TZ=UTC node --test                                      # 1186 pass, 0 fail
npm run test:unit:coverage
npx prettier --check tests/coverage-report-cli.test.mjs

tests/tools/coverage-report.mjs moves from 96.21 | 93.10 to 98.35 | 94.40 (line | region); all-files line coverage moves from 99.09% to 99.14%.

Related Issue

Closes #718


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88

Adds tests/coverage-report-cli.test.mjs, covering the reporter CLI paths that
tests/coverage-report.test.mjs cannot reach: it deletes NODE_V8_COVERAGE from
the reporter subprocess, so the reporter's own execution is never recorded and
only paths with an exit code of their own can be asserted on.

Covers parseArgs' passthrough of a bare node --test argument (76-78), the
"Not reported" notice for records made against loader-generated text
(570-578), and the non-zero exit when the spawned suite fails (580-583).

Line coverage of tests/tools/coverage-report.mjs moves 96.21 -> 98.35 and
region coverage 93.10 -> 94.40.

Closes #718

Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

@mrbobbytables

Copy link
Copy Markdown
Member

Superseded by #750, which consolidates this and 14 other test-only coverage PRs into a single reviewable change (commit cherry-picked unmodified, authorship and DCO preserved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] coverage gap: main() in tests/tools/coverage-report.mjs has three unexecuted CLI paths

1 participant