Repository navigation
test: executed coverage for tools/runtime_contract.py main() — tests/test_runtime_contract_main.py - #209
Conversation
main() had zero executed coverage: tests/test_runtime_contract.py imports only resolve() and base_image(), leaving lines 62-89 unexecuted. rebuild-rpms.yml shells out to the CLI three times -- line 98 gates the rebuild on --check, line 740 captures default stdout into $CONTRACT, and line 742 captures --base-image into $BASE_IMAGE, which is then the image argument to docker run inside the publish job's Hummingbird-only consumer transaction step that publish_gate.py requires before the consumer OCI tag may move. Drives main() in-process with a patched sys.argv so the assertions land on the real statements rather than on a subprocess the coverage report cannot see, and captures stdout and stderr separately because the workflow assigns stdout to a shell variable. Covers all four output modes, both precedence orderings between them, every refusal branch, and the committed config against the exact invocations the workflow makes. tools/runtime_contract.py: 57% -> 99% (only the __main__ guard remains). Closes #208 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.
Reviewed: Adds thorough executed coverage for tools/runtime_contract.py CLI entry point main(), covering output modes, error exit handling, and committed configuration paths. Clean trial merge and passes all tests. Carries maintainer 'hold' label; awaiting maintainer removal of hold and second independent review to satisfy merge policy.
Danathar
left a comment
There was a problem hiding this comment.
Reviewed at 226dd60. The only change is the new tests/test_runtime_contract_main.py; tools/runtime_contract.py and the existing tests are untouched. The 19 cases call main() in-process with sys.argv patched and stdout and stderr captured separately, and pytest --cov shows 99% of the module executed (only the if name guard is missed). Mutation check on my side: sending the refusal to stdout instead of stderr, dropping the empty-contract refusal, swapping the --base-image/--check precedence, and making --json print lines each break at least one test, so the tests hold the behaviour rebuild-rpms.yml depends on rather than restating it. Full suite passes at this head (421 passed) and after a trial merge of current main (430 passed); validate.py, factory_contract.py, runtime_contract.py --check and check_workflow_quoting.py pass. The hive hold label still needs a maintainer to remove it.
castrojo
left a comment
There was a problem hiding this comment.
Approved: Adds complete test coverage for tools/runtime_contract.py main() CLI entry point and all output/refusal modes in tests/test_runtime_contract_main.py. CI is green (3/3 checks passing) and git merge-tree confirms clean merge onto origin/main.
Test Improvement
Adds executed coverage for
main()intools/runtime_contract.py. Touches exactly one file: the newtests/test_runtime_contract_main.py. No production code changes.tests/test_runtime_contract.pyimports onlyresolve()andbase_image(), so lines 62-89 — argument parsing, all four output modes, the refusal path and the empty-contract refusal — were never executed by any suite.That CLI is on the atomic-publish path.
.github/workflows/rebuild-rpms.ymlshells out to it three times::98gates the whole rebuild on--checkbefore any wave starts:740captures default stdout into$CONTRACT:742captures--base-imageinto$BASE_IMAGE, which is then the image argument todocker runThe latter two run inside the publish job's "Validate Hummingbird-only consumer transaction" step, which
tools/publish_gate.py:106requires to succeed beforeghcr.io/.../utah-packages:latestmay move.Approach
Each case calls
main()in-process with a patchedsys.argv, so the assertions land on the real statements rather than on a subprocess the coverage report cannot see. stdout and stderr are captured separately, because that split is load-bearing: the workflow assigns stdout to a shell variable, so a refusal that printed to stdout would silently become$CONTRACTor$BASE_IMAGE.19 cases in three groups:
OutputModeTests— default,--json,--check,--base-image, plus both precedence orderings of theif/elifchain (the flags are not declared mutually exclusive, so that order is the contract a caller passing two flags gets).--base-imageis asserted to print the reference alone.RefusalTests— missing policy file, missing manifest, unparseable TOML, unpinned[base].image, an[unavailable]exception nobody requested, a missing[bluefin]section, an emptysectionslist, a non-listsections, a non-stringpackagesentry, and a contract resolving to nothing. Each asserts exit 1, anERROR:prefix on stderr, and empty stdout.CommittedConfigurationTests— the realconfig/bluefin-packages.toml+config/runtime-contract.tomlagainst the exact invocationsrebuild-rpms.ymlmakes.No existing test was modified, skipped or weakened.
Verification
Coverage for the module, before and after:
Line 93 is the
if __name__ == "__main__"guard.Disjointness
Claims
tools/runtime_contract.py::mainand the new filetests/test_runtime_contract_main.pyonly. Disjoint from the other open quality PRs in this repository: #192 claimstools/rebuild_matrix.py/tests/test_rebuild_matrix.py, and #200 claimstools/packit_workflow.pypackage_chunks/packit_workflow. No file, function or test file overlaps.Related Issue
Closes #208
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78