Skip to content

test(import-architectures): cover the seven uncovered sub-line regions - #678

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-import-architectures-regions
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-import-architectures-regions

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

scripts/import-architectures.mjs scored 100.00% line coverage but only 92.22% region coverage — the lowest region score of any shipped source file. Region coverage (#640) scores a maximal run of offsets sharing one V8 count, so it sees the ?? fallbacks, ternary arms and continue guards that line coverage hides whenever the rest of the line runs.

Seven executable regions never ran. Three of them are fail-closed paths (no hot-linking, no unmirrorable fetch, no special files) whose regression would have left the line score at 100%.

This PR adds tests/import-architectures-fallbacks.test.mjs (8 tests) and one new option on tests/helpers-import-sandbox.mjs. No production code is touched.

Line Region now covered Test
183 yamlParse(...) ?? {} in splitFrontmatter empty frontmatter block; title/organization fall back to the directory id
234 both arms of the image rewrite in cleanMarkdown a non-artwork remote image is demoted to [alt](url) and asserted to carry no ![...]; an artwork image is rewritten to /img/cncf-projects/... and mirrored
249 if (!relativeDestination) continue; in mirrorProjectAssets a single-segment artwork URL is skipped before any fetch — asserted via the absence of the Could not mirror warning the stubbed fetch would otherwise produce
280 paragraph?... ?? '' in firstParagraph a body of only a heading and a bullet list summarises to ''
305 false arm of entry.isFile() ? [path] : [] in walkFiles a FIFO in images/ is dropped by the walk, asserted via the absence of the extension warning it would otherwise trigger
338/339 both dimension ternaries in sanitizeArchitectureAssets an SVG with no viewBox and no width/height gains no viewBox and no NaN; a sized SVG still gains viewBox="0 0 320 240"

The 234, 338/339 rows each pair the new arm with its opposite arm, so "no hot-link" cannot be satisfied by dropping every image and "no NaN viewBox" cannot be satisfied by never adding one.

Helper change

runImportArchitectures gains an upstreamFifos option. A named pipe is the only directory entry that is neither a symlink, a directory, nor a regular file, so it is the only way to reach walkFiles' final rejection arm — the one that backstops the symlink defence from #548. cp -R in the existing git clone stub recreates a FIFO as a FIFO, so it reaches the importer exactly as an upstream special file would.

Verification

$ TZ=UTC node --test tests/import-architectures-fallbacks.test.mjs
# tests 8, pass 8, fail 0

$ npm run test:unit:coverage:check          # --check 97 --check-source 99
scripts/import-architectures.mjs | 100.00 | 100.00 |
src files                        | 100.00 |  98.39 | 5401/5401 lines

src files region coverage rises 97.95% → 98.39%; scripts/import-architectures.mjs reaches 100.00%. npx prettier --check and npx cspell are clean on both changed files.

Claimed ground

Files: tests/import-architectures-fallbacks.test.mjs (new), tests/helpers-import-sandbox.mjs.
Functions under test: splitFrontmatter, cleanMarkdown, mirrorProjectAssets, firstParagraph, walkFiles, sanitizeArchitectureAssets in scripts/import-architectures.mjs.
Disjoint from #676 (scripts/lib/mdx-active-content.mjs, tests/mdx-active-content.test.mjs) and from #674 (package.json coverage gate) — no file, function or threshold overlaps. This PR is a beneficiary of #674: it raises the source region number that #674 proposes to gate.

Related Issue

Closes #677


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

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

scripts/import-architectures.mjs scored 100.00% line coverage but only
92.22% region coverage -- the lowest region score of any shipped source
file. Seven executable regions never ran, three of them fail-closed
paths whose regression would leave the line score untouched.

Adds tests/import-architectures-fallbacks.test.mjs covering:

  L183  the '?? {}' fallback in splitFrontmatter for an empty block
  L234  both arms of cleanMarkdown's image rewrite -- a non-artwork
        remote image demoted to a plain link, and an artwork image
        rewritten to its mirrored /img/cncf-projects path
  L249  the 'continue' in mirrorProjectAssets for an artwork URL with
        no derivable mirror name, asserted to skip before any fetch
  L280  the "?? ''" fallback in firstParagraph for a body with no prose
  L305  the false arm of walkFiles' 'entry.isFile() ? [path] : []',
        reached with a FIFO in images/
  L338  both dimension ternaries in sanitizeArchitectureAssets -- an SVG
  L339  with no viewBox and no width/height gains no NaN viewBox, while
        a sized SVG still gains a real one

Adds an upstreamFifos option to runImportArchitectures; a named pipe is
the only entry kind that is neither symlink, directory nor regular file.

scripts/import-architectures.mjs now reports 100.00% region coverage and
source region coverage rises from 97.95% to 98.39%.

Closes #677

Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
@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 automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

@mrbobbytables

Copy link
Copy Markdown
Member

Superseded by #750, which consolidates this and 14 other test-only coverage PRs into a single reviewable change (commit cherry-picked unmodified, authorship and DCO preserved).

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] scripts/import-architectures.mjs: 7 uncovered sub-line branch regions (92.22% region coverage)

1 participant