Repository navigation
test(coverage): guard the v8-ignore hints in src/ so each ignored arm keeps the unit test it names - #601
Conversation
… keeps the unit test it names Every `/* v8 ignore */` hint hides its arm from both coverage runs: the bundle run it was written for and the unit run, which uses the same provider and has no option to disable source hints. The unit floor therefore cannot notice when the test a hint names is deleted or stops reaching the arm — config.ts still reports 100 % lines with configBlunderbussDelay.test.ts and configSweep.test.ts removed. __tests__/coverageIgnoreHints.test.ts pins what can be checked statically: every hint states a reason; every `ignore next` names a `<name>.test.ts` that exists and imports the hinted module (lgtm.ts:68, whose driver reaches the arm through the dispatcher, is recorded in a checked one-entry table); every `start`/`stop` block is a test-only hook whose exported functions some test still calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
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. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
There was a problem hiding this comment.
Read the tree at bc1b372, re-ran the suite, and fault-injected the guard. This looks correct to me.
Verified against the repository, not just the diff:
- The 25 hints the guard walks are real:
grep -rn "v8 ignore" src/at this head returns exactly the 7ignore nextarms and 6start/stopblocks the PR body claims (e.g.src/utils/config.ts:619,src/utils/auth.ts:18,src/plugins/tide.ts:235). src/labels/lgtm.ts:68indeed names no test, and the recorded driver is real:__tests__/label/lgtm.test.ts:796("a binding refused with a non-Error value fails the command with its string form") reaches the arm throughhandleIssueComment.rootimported from__tests__/utils/workflowYaml.ts:7resolves to the repo root as the file assumes.npx vitest run __tests__/coverageIgnoreHints.test.ts→ 39 passed. Fault injection: moving__tests__/utils/configBlunderbussDelay.test.tsaway makes exactly one case fail —src/utils/config.ts:619 names the unit test that drives the ignored arm— and restoring it goes green again. The guard is not vacuous (exist where this guard expects thempins that too).hookNames(line 85) only matchesexport function/export async function; a hook written asexport constwould yield an empty list and fail loudly via theno exported function between start and stopassertion — conservative, not a hole.
Scope matches Closes #600 — the issue's recommendation section describes this file almost verbatim, including the deliberate limitation (static guard only; no stripped-hints coverage run), which the issue records as an accepted decision. One new test file, nothing else touched, disjoint from the other held PRs as claimed.
Minor observation, not a defect: importsModule (line 77) requires a single-quoted relative specifier; an alias or double-quoted import of a hinted module would false-fail the guard. That is the repo's idiom today and the failure mode is loud, so fine as is.
I cannot approve (human signature), but a maintainer can take this on the strength of the checks above.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
/kind cleanup 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
…-ignore-hint-guard
The six reset*() hooks the block rule was written for are gone; the one start/stop block left (src/platform/index.ts:18) ignores the adapter-only PlatformScope, which the action never reaches from dist/index.js but runState.test.ts exercises. The rule now asks of every block what it asked of the hooks — each export inside is named by some test — without requiring the 'test-only hook' wording. lgtm.ts's recorded driver moves to line 65. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Merged 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Verified locally at head 46be372:
npx vitest run __tests__/coverageIgnoreHints.test.ts— 29/29 pass.- The premise is real and independently confirmed:
@vitest/coverage-v85 honours/* v8 ignore */source hints in every run with no option to disable them (its provider passes only vite-internal ignore rules toast-v8-to-istanbul, which exposesignoreClassMethods/ignoreNode/ignoreSourceCodebut no hint toggle), so neither coverage floor can see a hint's driving test disappear. A static guard is the right shape for this. - The guard is self-protecting: the first case asserts hints exist (
hints.length > 0, arm hints > 0, astartpresent), so a hint-free tree can't pass vacuously; thedriversOutsideTheHintescape hatch is keyed byfile:lineand currently holds exactly one entry (src/labels/lgtm.ts:65), with the reason (dist comment churn) documented inline. - Single new test file; no
src/,dist/or existing test touched, so it's trivially disjoint from the other open quality PRs.
Minor, not blocking: the file:line key of driversOutsideTheHint will go stale if lines shift above lgtm.ts:65 — the named-driver test will then fail with a clear message, which is annoying but self-diagnosing.
Looks correct to me.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
/kind cleanup |
Test Improvement
Adds
__tests__/coverageIgnoreHints.test.ts, a static guard over the 25/* v8 ignore */hints insrc/(7ignore nextarms, 6start/stoptest-only hook blocks, 11 files atmain@ 9acb046). Each arm-level hint says<name>.test.ts drives it, but@vitest/coverage-v8honours the hint in the unit run as well as the bundle run (same provider, no option to disable source hints), so neither floor can see the named test disappear: withconfigBlunderbussDelay.test.tsandconfigSweep.test.tsexcluded,npm run test:coveragestill passes every threshold and reportsconfig.tsat 100 % lines with neither619nor679listed. Details and the reproduction in #600.The guard asserts, for every hint:
--reason follows the hint (a barestopis exempt; its reason is on thestart)ignore nextnames<name>.test.ts drives it, the file exists under__tests__/, and it imports the hinted module (from '../../src/utils/config')src/labels/lgtm.ts:68, whose hint names no test, is recorded in a one-entry table (__tests__/label/lgtm.test.ts:796drives it throughhandleIssueComment; the comment text ships intodist/index.js, so naming it in the hint means repacking); the table is itself checkedstarthas astopin the same file, saystest-only hook, and eachexport functionbetween them is called by some testNo
src/,dist/, config or docs file is touched.Files / cluster claimed — one new file,
__tests__/coverageIgnoreHints.test.ts(readssrc/**/*.tsand__tests__/**/*.ts; imports onlyrootfrom__tests__/utils/workflowYaml.ts). Disjoint from every held PR: #591/#593/#597 (plugin, dispatcher and label unit tests), #595 (__tests__/setup.ts, config type guards), #596 (bundle scenario + e2e floor), #598 (__tests__/testUtils.ts, fixture ordering), #599 (tsconfig.test.json, existing-test type fixes).docs/contributing.mdis deliberately left alone because four of those PRs edit it; the file's header comment carries the rationale.Testing
npx vitest run __tests__/coverageIgnoreHints.test.ts— 39 passedconfigBlunderbussDelay.test.tsmoved away →config.ts:619 names the unit test that drives the ignored armfails; an uncited/* v8 ignore next -- probe */appended tosleep.ts→sleep.ts:13 names the unit test …fails;resetLabelCacherenamed →labeling.ts:91 is a test-only hook, exported and called from a testfails;lgtm.test.ts drives itadded tolgtm.ts:68without dropping the table entry →records out-of-hint drivers only for hints that still exist and still name no testfailsnpx vitest run— 192 files, 2512 passed, 75 skippednpx eslint __tests__/coverageIgnoreHints.test.ts— clean;tsc --noEmit --stricton the file — cleanRelated Issue
Closes #600
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88