Repository navigation
test: pin sourceBoundaryOffsets short-segment guard and multi-boundary sort - #1252
Merged
Merged
Conversation
…y sort sourceBoundaryOffsets (tests/tools/e2e-coverage-report.mjs) finds the generated offsets where a bundle's source map changes original source, and convertScript cuts each V8 range there so no sub-range straddles two modules. Two branches of that walk had no unit coverage, and both occur in real webpack/terser output: - the segment.length < 4 guard, which skips a segment that maps to no source. Without it segment[1] is undefined, which reads as a change of source and manufactures a boundary inside a module. - the ascending sort of the boundary list, never exercised because every existing fixture produces at most one boundary. splitRangeAtBoundaries walks the cut list assuming ascending order. Neither is visible in a percentage: a spurious cut splits one region in two without changing which lines ran. Both tests therefore assert on the reported regions count. Mutating the guard to 'if (false)' makes the first test report 2 regions instead of 1; reversing the comparator makes collectE2ECoverage throw 'No src/** coverage was attributable'. tests/tools/e2e-coverage-report.mjs 97.57% -> 97.98% regions; harness files 99.19% -> 99.32%. Closes #1251 Signed-off-by: quality <quality@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 keep the |
This was referenced Oct 9, 2026
[quality] 10 unreachable regions permanently cap tests/tools/e2e-coverage-report.mjs at 97.98%
#1253
Closed
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/e2e-coverage-source-boundary-segments.test.mjs, pinning twobranches of
sourceBoundaryOffsets(tests/tools/e2e-coverage-report.mjs) thathad no unit coverage. That function finds the generated offsets where a bundle's
source map changes original source;
convertScriptcuts each V8 range there sono sub-range straddles two modules, because v8-to-istanbul abandons a range
whose ends map to different sources (
source.js,if (start.source !== end.source) return {}).1 —
if (segment.length < 4) continue;A source map may emit a 1-fieldsegment: a generated column mapped to no source. Webpack and terser output
contains them.
segment[1]is thenundefined, so without the guard thesegment reads as a change of source — it manufactures a boundary that is not a
module edge, and leaves
previousSourceatundefinedso the next genuinesegment looks like a change too.
2 —
[...boundaries].sort((a, b) => a - b)Never invoked: every existingfixture (
tests/e2e-coverage-source-boundary.test.mjs) produces at most oneboundary.
splitRangeAtBoundarieswalks the cut list assuming ascending order,advancing
startto each cut in turn, so the sort is load-bearing for anybundle with three or more modules.
Both tests assert on the reported
regionscount, not on percentages: aspurious cut splits one region into two without changing which lines ran, so
linePercentandregionPercentare identical either way and would not catcha regression.
Mutation-tested
if (segment.length < 4) continue;→if (false) continue;.sort((a, b) => a - b)→.sort((a, b) => b - a)collectE2ECoveragethrowsNo src/** coverage was attributableCoverage
Measured locally with
npm run test:unit:coverage(node v26.10.0,TZ=UTC):tests/tools/e2e-coverage-report.mjsregionsharness filesregionsnpm run test:unit:coverage:checkpasses with the thresholdspackage.jsoncurrently sets, and the per-file harness figure clears both the current
--check-harness-file-regions 93and the 97 that #1250 proposes.Scope
Test-only: one new file under
tests/. No production code, no workflow files,no change to any existing test or threshold. Disjoint from the open PRs —
#1249 (
scripts/lib/uri-safety.mjs,tests/svg-active-content.test.mjs) and#1250 (
package.json,tests/coverage-gate-thresholds.test.mjs) — and from#1222 and #1232, which are both
.github/workflows/**.Related Issue
Closes #1251
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88