livery.extensions.coverage._parts¶
livery.extensions.coverage._parts ¶
The parts the measurers hand over, and the union the gate job writes.
Every measurer hands the coverage extension its readings as parts in
the line format (_format), one part per unit it measured, in one of
two ways. A measurer that reads its measurement inside its own step
leaves each unit's part in the workspace, under PARTS, as
<measurer>/<unit>.json: the cmake extension's test does, for a
native suite. A measurer whose run leaves data for later answers this
extension's coverage.measurers query with a Reduction, which
makes the parts when it is asked: the pytest extension does, for
coverage.py's data. A check leg gathers both for each unit it ran; the
gate job's union merges every leg's parts with the records' and writes
the merged files to UNION, which the floors read. On a machine the
floors' preview and the coverage pages read the parts the last run
left, both ways.
native tells which units the reductions are asked for: every unit
that holds the runtime's language; any other is native, and its
measurer leaves its parts itself.
Classes:
| Name | Description |
|---|---|
Reduction |
How an extension reduces the data its measurer left to parts. |
Unioned |
What the gate job's union wrote: the merged files and the units they came from. |
Functions:
| Name | Description |
|---|---|
measurers_by_name |
|
reduced |
What call, a reduction, returns; one that refuses stops the caller, named. |
native |
Whether package's suite is native, measured by its build's measurer. |
part_files |
Every part a measurer left under |
read_part |
The part in the file path, decoded. |
write_union |
Write combined, the union of units' parts, to |
read_union |
The union the gate job wrote at root; |
Attributes:
| Name | Type | Description |
|---|---|---|
PARTS |
|
|
UNION |
|
|
MEASURERS |
Query[Mapping[str, Reduction]]
|
|
MEASURERS
module-attribute
¶
Reduction ¶
Bases: Protocol
How an extension reduces the data its measurer left to parts.
An extension answers coverage.measurers with a reduction for
each measurer it reduces, by the measurer's name. Both methods
return parts as JSON holds them, in the line format; a part off the
format refuses, naming the reduction and the key. A reduction that
cannot reduce what it finds raises ValueError naming the cause,
and its caller stops on it.
Methods:
| Name | Description |
|---|---|
leg |
One part per unit, in the units' order, from the data a check leg left. |
left |
The parts of the data the measurer's last run on a machine left at root. |
leg ¶
One part per unit, in the units' order, from the data a check leg left.
Each unit is {"unit": <its path>, "tests": <the prefix its own
tests' contexts start with>, "within": [<the path prefixes of its
closure>]}, and a unit without within takes every file. A
unit's part holds the files of its closure the data names, each
as the unit's own tests and the code outside every test reached
it, and names the contexts that reached each line wherever the
data names a test. The record numbers the contexts when it
stores the part, so a reduction numbers them as it likes.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_parts.py
left ¶
The parts of the data the measurer's last run on a machine left at root.
Unioned
dataclass
¶
What the gate job's union wrote: the merged files and the units they came from.
Attributes:
| Name | Type | Description |
|---|---|---|
files |
Mapping[str, Merged]
|
Each file's merged reading, by its path from the root. |
units |
tuple[str, ...]
|
The units whose parts the union merged. |
left_out |
tuple[str, ...]
|
A line for each reading the merge left out. |
measurers_by_name ¶
coverage.measurers' rule: each answering extension's reductions, by measurer.
Raises:
| Type | Description |
|---|---|
ValueError
|
when two extensions reduce one measurer, naming both. |
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_parts.py
reduced ¶
What call, a reduction, returns; one that refuses stops the caller, named.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_parts.py
native ¶
Whether package's suite is native, measured by its build's measurer.
A suite is native when its package does not hold the runtime's language. A native suite's measurer leaves its parts itself, so the reductions are never asked for it, and a package whose suite left no part is not measured. The workspace's own tests hold the root's set, so they are native while that set does not hold the runtime's language.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_parts.py
part_files ¶
Every part a measurer left under PARTS at root, in name order.
read_part ¶
The part in the file path, decoded.
Raises:
| Type | Description |
|---|---|
PartError
|
when the file does not parse, or holds a part off
the format; the message names the file from root and the
key at fault. |
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_parts.py
write_union ¶
Write combined, the union of units' parts, to UNION; the path.
The merged files are grouped into one part per measurer, each numbering combined's contexts, so the file reads back with the line format's own reader.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_parts.py
read_union ¶
The union the gate job wrote at root; None when it wrote none.
Raises:
| Type | Description |
|---|---|
PartError
|
when the file is not a union this workshop wrote, naming the file and the key at fault. |