Documentation
¶
Overview ¶
Package coverage parses a test-coverage report (lcov, Cobertura XML, or JaCoCo XML) into per-file, per-line coverage. The format is auto-detected from the content. Read-only, size-bounded; returns the aggregated measure.CoverageReport plus the raw line map so a caller can compute new-code coverage (changed lines that are covered).
Index ¶
- type LineCoverage
- func Parse(path string) (measure.CoverageReport, LineCoverage, error)
- func ParseBytes(data []byte) (measure.CoverageReport, LineCoverage, error)
- func ParseBytesWithOptions(data []byte, opts Options) (measure.CoverageReport, LineCoverage, error)
- func ParseWithOptions(path string, opts Options) (measure.CoverageReport, LineCoverage, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LineCoverage ¶
LineCoverage maps a file path to (line number -> covered). A line present here is an executable line; absent lines are not counted.
func Parse ¶
func Parse(path string) (measure.CoverageReport, LineCoverage, error)
Parse reads a coverage report file, auto-detects its format, and returns the aggregated report plus the per-line map.
func ParseBytes ¶
func ParseBytes(data []byte) (measure.CoverageReport, LineCoverage, error)
ParseBytes parses coverage data whose format is auto-detected: XML with a <coverage> root is Cobertura, XML with a <report> root is JaCoCo, a `mode:` header is a Go -coverprofile, otherwise the data is treated as lcov.
func ParseBytesWithOptions ¶ added in v0.2.0
func ParseBytesWithOptions(data []byte, opts Options) (measure.CoverageReport, LineCoverage, error)
ParseBytesWithOptions is ParseBytes with format options.
func ParseWithOptions ¶ added in v0.2.0
func ParseWithOptions(path string, opts Options) (measure.CoverageReport, LineCoverage, error)
ParseWithOptions is Parse with format options.
func (LineCoverage) NewCodePercent ¶
NewCodePercent is coverage on new code. The measurement lives on the domain type so the server-side measures can compute it without importing this package; this is the same function.
type Options ¶ added in v0.2.0
type Options struct {
// GoModulePath is the `module` directive of the scanned tree. A Go -coverprofile names files by
// import path (module/pkg/file.go); with the module path known, that prefix is stripped so the
// result keys on repo-relative paths like every other format. Empty leaves Go paths untouched.
GoModulePath string
}
Options tunes parsing for formats whose file paths are not repo-relative on their own.