Repository navigation
test: unit coverage for tools/rebuild_matrix.py — tests/test_rebuild_matrix.py - #143
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
tools/rebuild_matrix.py was the only module under tools/ that no test imported and no test ran as a subprocess: 78 statements at 0%, executed only by .github/workflows/rebuild-rpms.yml in production. It is the half of the rebuild decision that talks to the outside world, and its uncovered paths are the ones that fail quietly rather than loudly: the absent/all-zero BASE_SHA guard that keeps a scheduled run from shelling out to an empty diff range, the base-commit inventory reads that deliberately prove nothing when the file is missing or unparseable, the mirror failure that rebuilds everything instead of skipping a package, and the stage-overflow SystemExit that stops the factory publishing a repository quietly missing those recipes. Add tests/test_rebuild_matrix.py: 23 cases over changed_recipes, changed_inventory, fetch_published and main. subprocess, urlopen and the module's ROOT are redirected at the module object, so every case runs the real functions against a synthetic factory tree with no network and no git repository. The zstd branch of fetch_published stands a recorder in for zstandard, so the branch is proven without adding a test dependency. Coverage of tools/rebuild_matrix.py goes 0% -> 99%, the remaining line being the __main__ guard. Suite goes 316 -> 339 passing. No production code is changed. Assisted-by: Claude Opus 5 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check[bot] <sec-check[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. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
|
Tracked in #153. Deferring this PR until that incident closes; please don't re-run the check per-PR.🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-opus-5 copilot=1.0.78 |
|
Blocked by the repository-wide CI incident, not by this diff. The This PR adds only Tracking in #153; deferring this PR until the baseline is green.🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78 |
castrojo
left a comment
There was a problem hiding this comment.
Substantive review:
- Test Coverage: Adds 23 unit tests in tests/test_rebuild_matrix.py covering tools/rebuild_matrix.py (changed_recipes, changed_inventory, fetch_published, and main driver execution).
- Isolation: All test cases use synthetic mock directories and URL openers without network dependency.
- Validation: Factory contract, validate.py, and unittest suite pass cleanly against current main.
- Outstanding: PR is hold-gated requiring human maintainer review to remove hold label and land.
|
Closing to consolidate the queue on the merged #178 full-factory candidate. The branch is retained; please re-open or submit a fresh, rebased PR after that build establishes the current baseline. |
1 similar comment
|
Closing to consolidate the queue on the merged #178 full-factory candidate. The branch is retained; please re-open or submit a fresh, rebased PR after that build establishes the current baseline. |
Test Improvement
Adds
tests/test_rebuild_matrix.py— 23 unit cases fortools/rebuild_matrix.py,the driver
.github/workflows/rebuild-rpms.ymlruns to decide what the factorybuilds.
Claimed ground:
tests/test_rebuild_matrix.py(new file, the only file inthis PR) covering
tools/rebuild_matrix.py::changed_recipes,changed_inventory,fetch_publishedandmain. No production file is touched, and no other moduleunder
tools/is claimed.Why this module
It was the only module under
tools/with no test at all. The three othermodules reporting 0% line coverage —
validate.py,check_workflow_quoting.py,check_build_container_pinning.py— are exercised as subprocesses by their owntest files, which coverage.py simply cannot see into.
rebuild_matrixhadneither:
grep -rn rebuild_matrix tests/ Justfilereturned nothing.What is covered
changed_recipes— absent, all-zero, short and non-hexBASE_SHAallshort-circuit before
subprocessis reached; package names are taken from thepath, not the file; paths outside
packages/and a barepackages/<name>entry name nothing; inventory changes are unioned in.
changed_inventory— an untouched inventory is never read out of git; a stagemove counts as changed and an identical entry does not; a missing or
unparseable inventory at the base commit proves nothing rather than everything.
fetch_published— an emptyFACTORY_REPOfetches nothing; a base URL with notrailing slash still joins correctly; both the gzip and the zstd primary are
decoded.
main— outputs are appended asGITHUB_OUTPUTlines; a full run never readsthe published repository; a published package is skipped and said so; a changed
recipe is rebuilt even when published; an unreachable mirror warns and rebuilds
everything rather than failing; a missing factory repository warns and skips
nothing; a stage split over 250 packages reports the split; a stage ≥ 11 stops
the run instead of silently dropping packages.
Method
subprocess,urllib.request.urlopenand the module'sROOTare redirected atthe module object, so each case runs the real functions against a synthetic
factory tree. No case touches the network or a real git repository. The zstd
branch stands a recorder in for
zstandard, so that path is proven withoutadding a test dependency the CI job does not install.
Evidence
Before, on
mainat a8ab8e0:After:
The one remaining line is the
if __name__ == "__main__"guard.The cases were checked against mutations rather than only against green: forcing
if not full:toif False:fails 2 cases, and dropping thechanged_inventoryunion fromchanged_recipesfails 1.Related Issue
Closes #142
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5