ci: add strict test evidence gates

This commit is contained in:
Joseph Magly
2026-08-14 11:44:12 -04:00
parent 2e703e19e2
commit 66c47249df
16 changed files with 443 additions and 6 deletions
+45
View File
@@ -0,0 +1,45 @@
"""Tests for the separate line/branch coverage policy gate."""
from __future__ import annotations
import importlib.util
from pathlib import Path
SCRIPT = Path(__file__).parents[1] / "scripts" / "check_coverage_thresholds.py"
SPEC = importlib.util.spec_from_file_location("check_coverage_thresholds", SCRIPT)
assert SPEC is not None and SPEC.loader is not None
MODULE = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(MODULE)
def _report(line: float = 49.0, branch: float = 36.0) -> dict[str, object]:
return {
"totals": {
"percent_statements_covered": line,
"percent_branches_covered": branch,
},
}
def test_validate_coverage_accepts_exact_floors():
assert MODULE.validate_coverage(
_report(), min_line=49.0, min_branch=36.0,
) == []
def test_validate_coverage_reports_each_regression():
failures = MODULE.validate_coverage(
_report(line=48.9, branch=35.9), min_line=49.0, min_branch=36.0,
)
assert failures == [
"line coverage 48.90% is below the 49.00% floor",
"branch coverage 35.90% is below the 36.00% floor",
]
def test_validate_coverage_rejects_malformed_totals():
assert MODULE.validate_coverage(
{}, min_line=49.0, min_branch=36.0,
) == ["coverage report is missing the totals object"]