Documentation
¶
Overview ¶
Package coverage parses a Go coverprofile and reports statement coverage over blocks not marked with a coverage-ignore directive. It backs the awf coverage gate (ADR-0012): a directive of the form "<slashes> coverage-ignore: <reason>" drops its block from both the covered and total counts; a directive with no non-empty reason is an error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶ added in v0.10.0
Filter returns a coverprofile containing exactly the blocks of the profile at profilePath that are NOT dropped by a coverage-ignore directive — the same blocks the ADR-0012 gate holds accountable, sharing ignoredLines verbatim so the two can never disagree on what "ignored" means (ADR-0065's covered report). The output carries a "mode: set" header (the mode parseProfile discards; awf's gate profile is always set) and merged-unique blocks in deterministic (file, startLine, span) order, so it round-trips as valid Codecov input.
func FilterProfile ¶ added in v0.10.0
FilterProfile resolves the module root from the working directory and returns the profile at profilePath with its coverage-ignored blocks removed (see Filter).
Types ¶
type Report ¶
type Report struct {
Covered int // statements in non-ignored blocks executed at least once
Total int // statements in non-ignored blocks
}
Report is the result of checking a coverprofile.
func Check ¶
Check parses the coverprofile at profilePath and returns a Report over blocks not marked for ignore. srcRoot is the module root on disk; modPath is the go.mod module path, used to map profile paths to files on disk.
A profile produced by `go test ./... -coverpkg=./...` emits each instrumented block once per test binary, so the same block recurs many times with differing counts. Blocks are first merged by identity (file + span), OR-ing the counts (mode: set), exactly as `go tool cover` does — otherwise the denominator is inflated by the duplication.
func CheckProfile ¶
CheckProfile resolves the module root from the working directory (nearest ancestor with a go.mod) and checks profilePath against the module sources.