Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[quality] Nothing verifies the unit test each v8-ignore hint in src/ says drives its arm; add a static guard over the 25 hints

已关闭
#600 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@hivecommons-hive 已经在做这个了。

开始于 2026年10月27日。

  • #601 来自 @hivecommons-hive —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
github-actions, typescript
领域
devtools, testing

调研方向

Start with the existing tests under tests and the v8 ignore hints in src/**/*.ts; the issue names tests/coverageIgnoreHints.test.ts as the proposed entry point. Add a static guard run by npm test that checks hint reasons, cited test files and imports, and test-only hooks against their callers. Confirm it catches the listed fault injections; issue 601 is an open linked pull request.

由索引模型根据 Issue 内容生成。

描述

agent/quality needs-kind stage/040-covered-by-pr testing

Finding

src/ carries 25 /* v8 ignore */ hints in 11 files (main @ 9acb046): 7 arm-level ignore next hints and 6 ignore start/stop blocks around the test-only reset*() hooks. Every arm-level hint was added for the bundle run (npm run test:coverage:e2e), where the arm is unreachable from dist/index.js, and each one records that a unit test still drives the arm — … unreachable from dist/index.js; configSweep.test.ts drives it.

Nothing checks that second half. @vitest/coverage-v8 5.0.5 honours the same hints in the unit run (same provider; node_modules/@vitest/coverage-v8/dist/provider.js:171 adds only vite-internal ignoreNode rules and exposes no option to disable source hints), so the arm is invisible to both floors. Demonstration on main @ 9acb046:

npx vitest run --coverage \
  --exclude __tests__/utils/configBlunderbussDelay.test.ts \
  --exclude __tests__/utils/configSweep.test.ts \
  --exclude __tests__/run.test.ts
# Test Files 188 passed, every threshold passes
# config.ts | 100 | 99.61 | 100 | 100 | 669

The two tests the hints at config.ts:619 and config.ts:679 name are gone, yet config.ts still reports 100 % lines and statements and neither 619 nor 679 is listed as uncovered. The only visible loss (669) is an unrelated branch configSweep.test.ts also covered. The same holds for auth.ts:18/20, command.ts:25, requireMatchingLabel.ts:169, run.ts:42 and lgtm.ts:68 (whose hint names no test at all; __tests__/label/lgtm.test.ts:796 drives it through the dispatcher). A future refactor that drops or rewrites one of those tests leaves a genuinely untested arm with a 100 % figure beside it.

This is a test-infrastructure gap, not a coverage gap: today every hinted arm is unit-covered (verified by reading each cited test), and the Stryker harness (stryker.config.mjs) does not cover these files or run in CI, so it is not a gate for this class either.

Recommendation

Add a static guard, __tests__/coverageIgnoreHints.test.ts, run by the ordinary npm test, that walks src/**/*.ts and asserts for every hint:

  • it states a reason after -- (a bare stop is exempt; the reason lives on its start);
  • an ignore next hint names <name>.test.ts drives it, that file exists under __tests__/, and it imports the hinted module (from '../../src/utils/config'), so the hint cannot outlive its test. src/labels/lgtm.ts:68 is recorded in a one-entry table inside the test (its driver reaches the arm via handleIssueComment, and the comment text ships into dist/index.js, so renaming it there means repacking the bundle); the table itself is checked so a stale entry fails;
  • every start has a stop in the same file, says test-only hook, and every export function between them is called by at least one test file — the hook can only be ignored while a test still uses it.

Fault injection on the proposed guard: deleting configBlunderbussDelay.test.ts → config.ts:619 names the unit test that drives the ignored arm fails; appending an uncited ignore next to sleep.ts → fails; renaming resetLabelCache → labeling.ts:91 is a test-only hook … called from a test fails; adding lgtm.test.ts drives it to lgtm.ts:68 without dropping the table entry → the table check fails. All 39 cases pass on main.

What the guard does not do, deliberately: it does not prove the cited test still reaches the arm (no provider option exists to run coverage with hints stripped; a vite plugin blanking the hint text in a second coverage config would, at the cost of a second full unit run). Decision taken by hive: ship the static guard now; the stripped-hints run is a follow-up only if the maintainers want it.

Priority

  • Impact: medium (a 100 % figure can sit beside an untested arm on merge-decision code — config.ts, auth.ts, requireMatchingLabel.ts)
  • Effort: low (one new test file, no src/, dist/ or docs change)

Filed by quality agent (hold-gated mode)


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 9acb046

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

主要语言
TypeScript
星标
132
派生
24
平均合并
1 天 12 小时
30 天内合并 PR
229

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cncf/prow-github-actions 的其他 Issue

查看 cncf/prow-github-actions 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。