Repository navigation
test(coverage): gate --require-source-files on unmappable source files - #1227
Merged
Merged
Conversation
`--require-source-files` walks scripts/, src/ and tests/tools/ and fails when a file there was never measured. It caught only one of the two ways a source file can leave every ratio. A file nothing imports is recorded nowhere and is named. A file that was executed but whose V8 record could not be attributed back to the text on disk is dropped by collect() into `unmapped`, and report() is built from the merged map alone, so it leaves the `src files` numerator and denominator together. The gate passed over it too, because main() folded `unmapped` into the measured set. That fold is right for the question missingSourceFiles asks -- counting an unmappable component as missing would make every one of them a permanent failure -- but nothing else asked the other question, and the only trace left was an informational notice nothing scores. Making tryRemapJsx decline one component left the full gate exiting 0 with src/components/CaseStudies/index.js (158 lines, 35 regions) gone from the denominator. The drift is reachable: tryRemapJsx compares the rebuilt loader output's length against the recorded text, so an swc bump or a change to tests/tools/jsx-hooks.mjs is enough. Adds unmappedSourceFiles(), claiming only paths inside SOURCE_ROOTS so the nine data/*.json modules go on being listed without failing anything, and a second condition under the same flag. The two diagnoses are now reported together rather than the first short-circuiting the second. 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 |
Closed
3 tasks
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
--require-source-filesis the repository's file-set floor, and it caught only one ofthe two ways a source file can leave every coverage ratio.
A file nothing imports is recorded nowhere, so
missingSourceFilesnames it and the gatefails. A file that was executed but whose V8 record could not be attributed back to
the text on disk is dropped by
collect()intounmapped, andreport()is built fromthe merged map alone — so it leaves the
src filesnumerator and denominator together.main()foldedunmappedinto the measured set, so the gate passed over it as well. Theonly trace left was the informational "Not reported" notice, which nothing scores.
That fold is deliberate and right for the question
missingSourceFilesasks — therationale is argued at
tests/coverage-report-source-files.test.mjs:139-151, and thischange leaves it and its test untouched. The fix is a second, separate condition under
the same flag.
Measured
At
593b9fe, node v26.10.0,TZ=UTC, locally.tryRemapJsxwas made to decline onecomponent, simulating the drift this guards against, and the full
npm run test:unit:coverage:checkwas run:src files8999/8999 lines, 2560/2561 regions(was9157/9157,2595/2596)158 lines and 35 regions of
src/components/CaseStudies/index.jshad left thedenominator with every gate still green.
The drift is reachable rather than hypothetical:
tryRemapJsxcompares the rebuiltloader output's length against the recorded text before trusting the offsets, so an
swc bump or a change to
tests/tools/jsx-hooks.mjsis enough to unmap any of the 19JSX-bearing modules under
src/.Unmodified, the gate still exits 0 at
src files 100.00 | 99.96 | 9157/9157 lines | 2595/2596 regions, and the ninedata/*.jsonmodules are still merely listed — only thetrees
--require-source-fileswalks are gated.What this changes
unmappedSourceFiles()intests/tools/coverage-report.mjsmain()fails under--require-source-fileswhen that list is non-empty, and reportsboth file-set diagnoses together instead of the first short-circuiting the second
tests/coverage-report-unmapped-sources.test.mjs— what is claimed, that the twodiagnoses stay disjoint, and an end-to-end run that fails on a module whose text
drifted after it was recorded
Verified non-vacuous: with the new condition disabled, the end-to-end test fails on
/could not be mapped onto the text on disk/.No new flag and no
package.jsonchange.Overlap with open PRs
tests/tools/coverage-report.mjsis also edited by open PR #1207, which adds the--check-harness*threshold family (parseArgs,report(), andmain()at thereport(merged)destructure and the threshold block below it). This change sits in the--require-source-filesfailure block between those hunks and touches no line either ofthem does; the new test file is its own. They are disjoint at hunk level and neither
needs to land first.
Related Issue
Closes #1226
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88