Skip to content

test(e2e): cover the istanbul readers in e2e-coverage-report.mjs - #1211

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/e2e-coverage-report-readers
Oct 9, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/e2e-coverage-report-readers

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Test Improvement

Refs #1210 — the coverage work is done here, but the issue also asks for the
per-file region floor to be ratcheted and that single line cannot be written
yet (see Scope / overlap below), so the issue stays open to track it.

This takes #1210's option 1 (export the readers) for the part that option
covers, and its option 2 (record the residual) for the part it does not.

tests/tools/e2e-coverage-report.mjs exports only sourcePathFromReference,
collectE2ECoverage, renderE2ECoverageReport, writeE2ECoverageReport and
main. The guards inside its four module-private istanbul readers —
getLineCoverage, getRegionCoverage, isPhantomRegion and
isContradictedRegion — defend against malformed istanbul objects, and
istanbul objects are built inside the module by v8-to-istanbul from the V8
payload. Reaching a guard from the public surface requires that library to emit
a shape it does not emit, which is why no probe driven through
collectE2ECoverage in #1208/#1209 could close them.

Exported the four readers for tests (tests/tools/e2e-coverage-report.mjs)
and added tests/e2e-coverage-report-readers.test.mjs — 19 tests driving the
guards directly with hand-built istanbul objects:

  • getLineCoverage — absent s; statements whose map entry is missing, has no
    start, or has a non-integer line; the highest-count-wins fold on one line.
  • getRegionCoverage — absent b; a branch with no branchMap entry and one
    with no locations; null/empty/non-integer-line locations; the
    end/column defaults; a branch with no counts array and one with a short
    one.
  • isPhantomRegion — executed region, single-line zero, inverted span, the
    statement-free line skipped mid-span, and the unexecuted line that keeps the
    zero.
  • isContradictedRegion — executed region, no script recorded the zero, a
    witness with no executable line in the span, a witness that left a span line
    unexecuted, a witness carrying a zero over the span, the same-script witness
    that does contradict, and the other-script witness that is correctly ignored.

Recorded the residual that exporting cannot reach, as an in-file note at
the top of the module naming each entry by function and expression rather than
by line so it does not go stale: normalizeSourceMap's
map.resolvedSources ?? … (@jridgewell/trace-mapping internals),
convertScript's converter.branches ?? {} / converter.functions ?? {} and
the .map(([path]) => path) arm behind them, collectE2ECoverage's
converted.coverage ?? {} and if (lineCoverage.size === 0) continue, and
main's error.message ?? String(error) / error.stack ?? error.

Measured

npm run test:unit:coverage, node v26.10.0, TZ=UTC, run locally at
593b9fe (this branch's base):

lines regions
before 100.00 93.65
after 100.00 96.28

All-files regions 95.20 → 95.34. Full unit suite: 2105 tests, 0 failures.
npm run check and npm run test:unit:coverage:check both exit 0; Prettier
clean.

Scope / overlap


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

The four module-private readers in tests/tools/e2e-coverage-report.mjs --
getLineCoverage, getRegionCoverage, isPhantomRegion and
isContradictedRegion -- carry guards against malformed istanbul objects.
Those objects are built inside the module by v8-to-istanbul from the V8
payload, so no capture artifact written at the public boundary can reach a
guard; 13 regions survived every probe driven through collectE2ECoverage.

Export the four readers for tests and drive their guards directly with
hand-built istanbul objects. Record the regions that remain unreachable
even so -- AnyMap internals, v8-to-istanbul's own converter fields, and two
non-Error rejection paths in main() -- as an in-file note naming each by
function and expression rather than by line.

tests/tools/e2e-coverage-report.mjs: 93.65% -> 96.28% regions, lines
unchanged at 100.00%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive hivecommons-hive Bot added the hold label Oct 8, 2026
@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 keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@mrbobbytables

Copy link
Copy Markdown
Member

Heads-up: PRs 1233 1240 also edit tests/tools/e2e-coverage-report.mjs. Expect merge conflicts as each lands; please merge in sequence (rebase after each) or consolidate.

@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit facf9be Oct 9, 2026
7 checks passed
mrbobbytables added a commit to mrbobbytables/endusers that referenced this pull request Oct 11, 2026
…ide the harness floor (cncf#1287)

Resolves cncf#1253 by the same route cncf#1211 took for cncf#1210: document the
unreachable fallbacks rather than delete them or add an ignore marker.

tests/tools/e2e-coverage-report.mjs sits at 97.98% regions and every one
of its 10 uncovered regions is a defensive fallback no test can reach.
The in-file note already listed eight of them; this adds the two it
predates (the second fallback on the resolvedSources chain, and the
parts.length === 0 arm in splitRangeAtBoundaries from cncf#1240), states the
resulting ceiling, and says how the list and the floor move together.

tests/coverage-gate-thresholds.test.mjs records that ceiling next to
--check-harness-file-regions so the floor cncf#1250 raised to 97 is never
set above what the file can measure, and refreshes the measured numbers
to the suite this commit ships.

Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Approved by a Hive merger/owner for auto-merge on green CI hive/hosted-available-lke648397-260827-5n31 Approved by a Hive merger/owner for auto-merge on green CI hold quality Approved by a Hive merger/owner for auto-merge on green CI testing Approved by a Hive merger/owner for auto-merge on green CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant