test(coverage-report): cover collect()'s merge and record-skip paths - #702
Open
hivecommons-hive[bot] wants to merge 1 commit into
Open
hivecommons-hive[bot] wants to merge 1 commit into
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
collect() reads the raw NODE_V8_COVERAGE dump, folds each sandbox URL back onto the real source tree, and merges every process's record for a file into one per-offset count map. Every coverage gate scores what it returns. It had no direct test, and its own execution is invisible to the report it produces: the reporter runs collect() in the parent process and sets NODE_V8_COVERAGE only for the node --test child it spawns. Add tests/coverage-report-collect.test.mjs, driving collect() against a hand-built coverage directory and a fake repository root so the merge arithmetic and each skip-this-record fallback are pinned independently of whatever the real suite happens to execute. Closes #701 Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
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 Hive will automatically remove the |
This was referenced Sep 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Improvement
Adds
tests/coverage-report-collect.test.mjs— the first direct test ofcollect()intests/tools/coverage-report.mjs.collect()reads the rawNODE_V8_COVERAGEdump, folds each sandbox URL backonto the real source tree, and merges every process's record for a file into one
per-offset count map.
--check,--check-regions,--check-sourceand--check-source-regionsall score exactly what it returns.It had no direct test, and its own execution is structurally invisible to the
report it produces: the reporter runs
collect()in the parent process andsets
NODE_V8_COVERAGEonly for thenode --testchild it spawns. So aregression in the merge would not fail anything — it would silently move the
published percentage.
What the 12 tests pin
file unexecuted merge to fully covered
.jsondirectory entries are ignored even when they contain validcoverage JSON, so the extension filter cannot hide behind the
malformed-file fallback
unmappedunmappedunmappedonce any record maps onto itEach test builds its own coverage directory and fake repository root under
os.tmpdir()and removes it afterwards, so nothing depends on what the realsuite happens to execute.
Verification
Measured on a clean
npm ciatb54cf81:tests/tools/coverage-report.mjslinestests/tools/coverage-report.mjsregionsPreviously-unexecuted lines 437-438, 447-448 and 470-473 are now covered.
Mutation-checked, so the tests are not vacuous. All four of these mutants
survive on
mainand are killed by this PR:if (counts[i] > existing.counts[i]) existing.counts[i] = counts[i];→existing.counts[i] = counts[i];if (!entry.endsWith('.json')) continue;→ removedfor (const relPath of merged.keys()) unmapped.delete(relPath);→ removedunmapped.add(relPath);→ removednpx prettier --checkandnpx cspellboth pass on the new file. No productioncode, no existing test, and no shared helper is touched — the diff is one new
file under
tests/.Disjointness
This claims
tests/coverage-report-collect.test.mjsand thecollect()functionin
tests/tools/coverage-report.mjs. No open PR touches either: #674 changespackage.jsononly, #678 claimstests/helpers-import-sandbox.mjs, #693 claimstests/helpers-script-sandbox.mjs, and #680, #686, #688, #676, #684, #691 claimunrelated validator, collector and security files.
Related Issue
Closes #701
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88