Skip to content

test(coverage): cover the coverage-run CLI's non-Error rejection fallback - #1174

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/test-coverage-run-cli-non-error
Oct 8, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/test-coverage-run-cli-non-error

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds one case to tests/e2e-coverage-run.test.mjs covering the ?? error
fallback in the CLI entrypoint of tests/tools/e2e-coverage-run.mjs:

209 main().catch((error) => {
210   console.error(error.stack ?? error);   // line 211
211   process.exitCode = 1;
212 });

The existing sibling case (tests/e2e-coverage-run.test.mjs:229) spawns the
tool with a bogus command, where main() throws new Error(...). That covers
the error.stack side and left the fallback beside it as the file's only
uncovered region.

Why the fallback matters. .github/workflows/ci.yml:231 and :248 run this
tool as a command, and its stderr is the only account the End-to-end coverage
job gives of why it stopped. A rejection that is not an Error has no .stack;
without the fallback that log would read undefined and nothing else.

How the case reaches it. Every throw in the tool is new Error(...), so
main() never rejects with a stackless value on its own. A --import prelude
makes the one host call main() issues on its success path — the
process.stdout.write() of the manifest — throw a bare string, so the rejection
arrives at the entrypoint in exactly the shape a non-Error would. The init
itself succeeds first, which keeps the case about the reporting path rather than
about the command; the test asserts that by reading the manifest back.

The case asserts exit status 1, that stderr carries the thrown value, and
explicitly that stderr does not contain undefined — the failure mode the
fallback exists to prevent.

Verification

TZ=UTC node tests/tools/coverage-report.mjs (node v26.10.0), run locally on
this branch:

before after
tests/tools/e2e-coverage-run.mjs 100.00 | 98.65 | 211 100.00 | 100.00

npm run test:unit:coverage:check exits 0 on this branch. No threshold in
package.json:70 is changed, and no workflow file is touched.

Scope

One new test case in one existing file. It does not edit
tests/tools/e2e-coverage-report.mjs or tests/e2e-coverage-report.test.mjs
(#1163), tests/tools/e2e-data-fixtures.cjs,
tests/e2e/fixtures/data-variants/metrics.json or
tests/e2e-data-fixtures.test.mjs (#1171),
tests/architecture-content-mirror.test.mjs (#1165), scripts/audit-gate.mjs
(#1161), or CONTRIBUTING.md (#1166).

Related Issue

Closes #1173

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

…back

tests/tools/e2e-coverage-run.mjs reports a rejection as
`error.stack ?? error`. The existing CLI case spawns the tool with an
unknown command, where main() throws an Error, so it covers the
`error.stack` side and leaves the `?? error` fallback as the file's
only uncovered region (98.65% of regions, line 211).

The fallback is what .github/workflows/ci.yml depends on for its
diagnostic: it runs this tool as `node tests/tools/e2e-coverage-run.mjs
init|seal`, and a rejection that is not an Error has no .stack, so
without the fallback the End-to-end coverage job's log would read
`undefined` and nothing else.

Reaching it needs main() to reject with a stackless value, which the
tool's own code never does. A --import prelude makes the one host call
on the success path -- the process.stdout.write() of the manifest --
throw a bare string, so the rejection arrives at the entrypoint in
exactly the shape a non-Error would. The init succeeds first, keeping
the case about the reporting path rather than about the command.

tests/tools/e2e-coverage-run.mjs now reports 100% region coverage.

Closes #1173

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive hivecommons-hive Bot added the hold label Oct 7, 2026
@hivecommons-hive

Copy link
Copy Markdown
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 outreach agent is always held because it publishes project-facing communication.

Hive will keep the hold label until a human removes it. 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.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] the coverage-run CLI's non-Error rejection fallback is its only uncovered region

1 participant