Repository navigation
test: executed coverage for tools/rebuild_matrix.py — tests/test_rebuild_matrix.py - #192
Conversation
…ild_matrix.py tools/rebuild_matrix.py is the driver .github/workflows/rebuild-rpms.yml runs to decide which packages a rebuild builds, and it reported 0% of its 104 statements. tests/test_factory_witness.py names the file but only reads it as text, so nothing ever executed it. Adds tests/test_rebuild_matrix.py: 31 cases over changed_recipes, changed_inventory, fetch_primary, hummingbird_baseurl, fetch_published and main(). subprocess, urllib.request.urlopen and the module's ROOT are redirected at the module object, so no case touches the network or a real git repository. Covered decisions that had nothing holding them in place: the base-sha guard that keeps a scheduled run from shelling out to an empty diff range; the inventory reader that proves nothing rather than everything when the old config is absent or unparseable; the mirror failure that rebuilds everything instead of skipping; the stale and dependent-drag rebuild reasons; the >250-package chunk split; and the SystemExit on a stage with no job. Coverage for the module goes 0% -> 99%; the remaining line is the __main__ guard. Suite goes 396 -> 427 passed. 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 |
castrojo
left a comment
There was a problem hiding this comment.
Merged origin/main to resolve the post-#191 baseline drift (dropping the 7 deferred base packages) and updated tests/test_rebuild_matrix.py to scaffold config/hummingbird-provided-sources.json and reflect that FACTORY_REPO is queried on FULL=1 for source pruning. Full test suite and validation gates pass cleanly.
Danathar
left a comment
There was a problem hiding this comment.
Reviewed at d1dbde4. The only change is the new tests/test_rebuild_matrix.py; no tool or existing test is touched. The 31 cases call the real functions with subprocess, urllib and ROOT patched at the module, so nothing hits git or the network, and pytest --cov reports 97% of tools/rebuild_matrix.py executed (only the zstandard branch is skipped here, since that module is not installed). To check the tests hold behaviour rather than text, I made four one-line mutations to tools/rebuild_matrix.py (dropping the all-zero BASE_SHA guard, dropping the stage-11 SystemExit, opening GITHUB_OUTPUT with w instead of a, and dropping the stale rebuild reason) and each one made exactly one test fail. The full suite passes at this head (432 passed) and after a trial merge of current main (441 passed), and validate.py, factory_contract.py, runtime_contract.py --check and check_workflow_quoting.py pass.
hanthor
left a comment
There was a problem hiding this comment.
The tests are good and pass at the PR head, but they've drifted from main. After a local merge with main, tests/test_rebuild_matrix.py:450-459 (test_a_stage_with_no_job_is_fatal) errors with ValueError: unknown stage for late: 11 from tools/package_inventory.py:73. Since #232, load_source_locks rejects out-of-range stages before main() reaches the "no job exists for stage 11" check the test expects.
Please rebase, then either assert the new earlier error or inject the lock past the validator. Everything else is ready. It would be good to land this before #195 so these tests guard that refactor.
|
Verification & Status:
Next action: Author (@app/hivecommons-hive or maintainer) must update |
…ut format Assisted-by: Gemini via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
castrojo
left a comment
There was a problem hiding this comment.
Rebased on origin/main and resolved test drift in tests/test_rebuild_matrix.py (commit db6cacc): added dummy sources file in write_root fixture for factory_state hashing, updated output string assertions to match current format (diff changed string, wave naming, trusted output list, and KNOWN_STAGES ValueError). All 30 tests in the file and 684 suite tests pass cleanly. Ready for @hanthor to re-review and clear CHANGES_REQUESTED.
Danathar
left a comment
There was a problem hiding this comment.
Re-review at db6cacc. hanthor's point is fixed: test_a_stage_with_no_job_is_fatal now asserts the ValueError "unknown stage for late: 11" that load_source_locks raises first, which was one of the two options he offered, and the other drift fixes only follow main's new output text (wave, trusted list, change detection). Locally the file passes (30 passed, 1 skipped) and the full suite passes (684 passed). Four one-line mutations to tools/rebuild_matrix.py each fail one test: dropping the all-zero BASE_SHA guard, opening GITHUB_OUTPUT with "w", dropping the stale rebuild reason, and letting stale builds stay cacheable. One gap, which can be a follow-up: the SystemExit for a BuildRequires chain deeper than the workflow's waves is no longer covered (disabling it passes the whole suite), so the description's "SystemExit on a stage with no job" bullet is out of date.
Point-by-point: (1) 'drifted from main; test_a_stage_with_no_job_is_fatal errors with ValueError unknown stage for late: 11' -> fixed in db6cacc, which rebases on main and asserts the ValueError that load_source_locks now raises first (the first option offered). (2) 'please rebase' -> db6cacc sits on current main. Verified: tests/test_rebuild_matrix.py 30 passed, full suite 684 passed locally at db6cacc; Canary green (run 36268047543); Danathar approved at db6cacc.
Test Improvement
Adds
tests/test_rebuild_matrix.py. Touches exactly one file, and it is a newtest file — no production code and no existing test is modified.
tools/rebuild_matrix.pyis the driver.github/workflows/rebuild-rpms.yml:240runs to decide which packages a rebuild builds, and it reported 0% of its 104
statements.
tests/test_factory_witness.py:129names the file, but only readsit as text (
REBUILD_MATRIX.read_text()), so nothing ever executed it.What is now covered
31 cases over
changed_recipes,changed_inventory,fetch_primary,hummingbird_baseurl,fetch_publishedandmain().subprocess,urllib.request.urlopenand the module'sROOTare redirected at the moduleobject, so no case touches the network or a real git repository.
The decisions that had nothing holding them in place:
BASE_SHAmust readno range at all; the tests assert
subprocess.check_outputis never called,not merely that the result is empty. Were that guard to regress, every
scheduled run would shell out to
git diff <empty>..HEADand fail the job.changed_inventoryproving nothing rather than everything when the oldconfig is absent or unparseable at the base commit, plus the case it exists
for: a stage move, invisible in the published NEVR.
fetch_primary— the repomd indirection, the trailing slash that has tobe added exactly once, and both decompression paths (the
.zstcase isgated on
zstandardbeing importable, and was run with it installed).Hummingbird listing being unreachable is survivable rather than fatal.
rebuild <name>: published build requires <cap>, which nothing providesandrebuild <name>: depends on something being rebuilt, and that a stale package is kept out ofcacheableso the cache cannot hand back the broken build.and never the selection — a stage above the 256-job cap expands to nothing
rather than failing.
SystemExiton a stage with no job, which is the guard that stops thefactory publishing a repository quietly missing those packages.
GITHUB_OUTPUTis appended to, not rewritten over the other steps in the job.Verification
Coverage evidence, on this branch:
Before, on
mainat3d38215:0% -> 99%; the one remaining line is the
if __name__ == "__main__"guard,which is not reachable under import. Suite 396 -> 427 passed, no pre-existing
test changed.
just check(tools/factory_contract.py,tools/validate.py)also passes.
End-to-end evidence: this repository has no end-to-end suite, so the module was
covered by neither unit nor end-to-end tests. Nothing here claims end-to-end
coverage.
Related Issue
Closes #142
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78