Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions messagefoundry/_diffcov_probe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""TEMPORARY diff-coverage probe — DELETE BEFORE MERGE. Not part of the engine.

Exists for one reason: four merged PRs surfaced the advisory quality gates, and the headline claim of
that work — that diff-cover emits INLINE `::notice` annotations on the Files changed tab — has never
been observed on a real diff, because none of those PRs touched `messagefoundry/` and `--cov` only
measures this package. The mechanism is proven locally and the CI path provably executes, but "it
reports correctly that there was nothing to report" is not the same as "it renders".

This module supplies real changed lines under coverage: `probe_covered` is exercised by
tests/test_diffcov_probe.py, `probe_uncovered` deliberately is not. A correct run annotates only the
latter — which proves both that the surface renders AND that it is scoped to genuinely uncovered
changed lines rather than to the whole diff.

Delete this file and its test once the annotation has been observed.
"""


def probe_covered(value: int) -> int:
"""Exercised by the probe test, so these lines must NOT be annotated."""
doubled = value * 2
return doubled


def probe_uncovered(value: int) -> str:
"""Deliberately unexercised. Every line below should come back as a `Missing Coverage` notice,
coalesced into as few ranges as diff-cover can manage."""
if value > 100:
label = "large"
elif value > 10:
label = "medium"

Check notice on line 30 in messagefoundry/_diffcov_probe.py

View workflow job for this annotation

GitHub Actions / diff-coverage (advisory)

Missing Coverage

Line 27-30 missing coverage
else:
label = "small"
suffix = "!" if value < 0 else ""
return f"{label}{suffix}"

Check notice on line 34 in messagefoundry/_diffcov_probe.py

View workflow job for this annotation

GitHub Actions / diff-coverage (advisory)

Missing Coverage

Line 32-34 missing coverage
13 changes: 13 additions & 0 deletions tests/test_diffcov_probe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""TEMPORARY — companion to messagefoundry/_diffcov_probe.py. DELETE BEFORE MERGE.

Covers `probe_covered` and pointedly not `probe_uncovered`, so the diff-coverage job has a real diff
with a mix of covered and uncovered changed lines to annotate.
"""

from messagefoundry._diffcov_probe import probe_covered


def test_probe_covered_doubles() -> None:
assert probe_covered(21) == 42
assert probe_covered(0) == 0
assert probe_covered(-3) == -6
Loading