Documentation
¶
Overview ¶
Package coverage renders a cover profile as HTML, colored by whether each function carries a direct unit test rather than by statement counts alone.
`go tool cover -html` paints a statement green once anything has executed it, which is exactly the confusion tarp exists to correct: a function reached only on the way to somebody else's assertion looks identical to one with a test of its own. This package keeps the familiar layout and splits that green in two — green for a function a TestXxx body references directly, yellow for one that merely ran. Red still means never executed at all, and code tarp does not grade (init, main, generated, ignored) is left grey so the view never claims more than the analysis does.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyProfile = platformerrors.New("the cover profile describes no files")
ErrEmptyProfile is returned when a profile parses but describes nothing. An empty profile usually means `go test` matched no packages, and rendering a blank page for it would hide that.
var ErrUnresolvedFile = platformerrors.New("no source file found for a file named in the cover profile")
ErrUnresolvedFile is returned when a file named in the profile cannot be found on disk. The usual cause is running against a different checkout than the one the profile was produced from.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Report is the analysis of the same packages the profile covers. Its
// verdicts are what separates green from yellow; a file the report says
// nothing about is rendered, but grey. Its file list also resolves the
// profile's package-relative names to sources, sparing a second load of
// packages this one has already read.
Report *analysis.Report
// Dir is the directory the profile's package paths are resolved against.
// Empty means the current working directory.
Dir string
// Profile is the path to a cover profile written by `go test -coverprofile`.
Profile string
}
Config selects the profile to render and the analysis to render it against.