Skip to content

test: guard test:coverage against new silent --exclude flags - #460

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-coverage-exclude-guard
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-coverage-exclude-guard

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Generalizes the regression test added in #427 (which only checked that
docusaurus.config.ts isn't re-excluded from the test:coverage c8 gate)
into a full assertion that test:coverage's --exclude flags equal exactly
['lib/testHelpers/**']. Any future --exclude flag carving a new blind
spot out of the 100% coverage gate now fails this test instead of merging
silently.

Verified locally: the new test passes against the current package.json,
and fails (confirmed via a temporary extra --exclude flag, then reverted)
when a second exclude is added - so it actually catches the regression it
guards against. npm run test:coverage still reports 100%
stmts/branch/func/line on every file, and npx prettier --check passes.

Related Issue

Fixes #459


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

-- hive: agent=quality backend=copilot model=claude-sonnet-5 copilot=1.0.88

Generalizes the existing docusaurus.config.ts-specific regression test into
a full assertion that test:coverage's --exclude list is exactly
['lib/testHelpers/**'], so any future --exclude flag hiding a file from the
100% coverage gate fails this test instead of merging silently.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added the ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge. label Dec 2, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Ready for review: held for a maintainer 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 outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

The hive's work on this PR is done. Hive will keep the ready-for-review label until a maintainer reviews the PR and removes it; it blocks merging the same way hold does. 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.

@netlify

netlify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

Name Link
🔨 Latest commit 156b964
🔍 Latest deploy log https://app.netlify.com/projects/cncf-techdocs/deploys/6b0fbd2fd189b8d8e217351c
😎 Deploy Preview https://deploy-preview-460--cncf-techdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read scripts/coverage-thresholds.test.mjs at 156b964 against package.json:39 on main (05422fc) and ran the new test locally; it passes on the current script. The intent matches #459 and the test is wired into test:unit via scripts/**/*.test.mjs, so it does run.

One gap worth closing before this lands: the extraction regex only recognises the single-quoted --exclude '…' spelling, so the guard does not yet do what its name and assertion message promise ("any other exclude flag ... fails this test"). Details and a drop-in suggestion are on the line. Nothing else found; the rest of the change looks correct to me.

Not a blocker, just for the record: c8 also reads --exclude from .c8rc* files and a "c8" key in package.json. Neither exists today, so a script-string check is a fair guard for now.

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

Comment on lines +62 to +64
const excludes = [...script.matchAll(/--exclude\s+'([^']*)'/g)].map(
(match) => match[1],
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium - this pattern only matches --exclude '<path>' with single quotes. I checked the four other spellings c8 accepts against this regex and each one leaves excludes as ['lib/testHelpers/**'], so the assertion still passes and the new exclude merges silently - exactly the regression this test is meant to stop:

  • --exclude=src/x.ts
  • --exclude src/x.ts (unquoted)
  • --exclude "src/x.ts" (double quotes)
  • -x src/x.ts (c8's short alias)

This also makes the assertion message at line 69-70 ("any other exclude flag ... hides a file") overstate what is enforced.

Verified this replacement returns ['lib/testHelpers/**'] for the current script and catches all four forms above:

Suggested change
const excludes = [...script.matchAll(/--exclude\s+'([^']*)'/g)].map(
(match) => match[1],
);
const excludes = [
...script.matchAll(/(?:--exclude|-x)(?:=|\s+)(?:'([^']*)'|"([^"]*)"|(\S+))/g),
].map((match) => match[1] ?? match[2] ?? match[3]);

@nate-double-u

Copy link
Copy Markdown
Member

/hive this repo only has a website as a part of the deploy preview process. This repo is published on the contribute.cncf.io site, which has its own static site generator and doesn't use this one. This repo doesn't need tests updates for it's website.

closing as not planned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] test:coverage gate only guards against re-excluding docusaurus.config.ts, not any other new --exclude

1 participant