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 ¶
- func CanonicalBaseline(baseline Baseline) ([]byte, error)
- func Filter(profilePath, srcRoot, modPath string) (string, error)
- func FilterProfile(profilePath string) (string, error)
- type Analysis
- type Baseline
- type Directive
- type DirectiveAdmission
- type EquivalentMutant
- type Finding
- type Identity
- type IgnoreClass
- type MissAdmission
- type PlatformDirective
- type Position
- type Report
- type Review
- type Selector
- type SelectorBaseline
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalBaseline ¶ added in v0.40.0
CanonicalBaseline validates and renders a byte-stable baseline.
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 Analysis ¶ added in v0.40.0
type Analysis struct {
ModulePath string
Raw Report
Filtered Report
RawMisses []Identity
UniverseSHA256 string
Selectors []Selector
ProductionDirectives []Directive
TestDirectives []Directive
}
Analysis is the policy view of one merged whole-module profile and its source tree.
func Analyze ¶ added in v0.40.0
Analyze parses one whole-module profile into the canonical raw policy model.
func AnalyzeProfile ¶ added in v0.40.0
AnalyzeProfile resolves the module root and analyzes one whole-module profile.
type Baseline ¶ added in v0.40.0
type Baseline struct {
Version int `json:"version"`
ModulePath string `json:"modulePath"`
UniverseSHA256 string `json:"universeSHA256"`
Repository []MissAdmission `json:"repository"`
Selectors []SelectorBaseline `json:"selectors"`
ProductionDirectives []DirectiveAdmission `json:"productionDirectives"`
TestDirectives []Directive `json:"testDirectives"`
PlatformDirectives []PlatformDirective `json:"platformDirectives"`
EquivalentMutants []EquivalentMutant `json:"equivalentMutants"`
}
Baseline is the canonical generated coverage policy artifact.
func LoadBaseline ¶ added in v0.40.0
LoadBaseline loads strict, canonical baseline evidence.
type Directive ¶ added in v0.40.0
type Directive struct {
File string `json:"file"`
Line int `json:"line"`
TargetLine int `json:"targetLine"`
Reason string `json:"reason"`
Mapped bool `json:"mapped"`
Executed bool `json:"executed"`
}
Directive describes one coverage-ignore directive and its relationship to the measured whole-module profile.
type DirectiveAdmission ¶ added in v0.40.0
type DirectiveAdmission struct {
Directive Directive `json:"directive"`
Class IgnoreClass `json:"class"`
Evidence string `json:"evidence"`
}
DirectiveAdmission records the reviewed class and evidence for one retained production directive.
type EquivalentMutant ¶ added in v0.40.0
type EquivalentMutant struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Mutator string `json:"mutator"`
Reason string `json:"reason"`
}
EquivalentMutant is an exact independently reviewed equivalent survivor.
type Identity ¶ added in v0.40.0
type Identity struct {
File string `json:"file"`
Start Position `json:"start"`
End Position `json:"end"`
Statements int `json:"statements"`
}
Identity is the exact identity of one coverprofile block.
type IgnoreClass ¶ added in v0.40.0
type IgnoreClass string
IgnoreClass is one admitted production coverage-ignore class.
const ( IgnoreProcessExit IgnoreClass = "tested-process-exit" IgnoreImpossibleState IgnoreClass = "revalidated-impossible-state" IgnoreDeterministicFault IgnoreClass = "uninducible-deterministic-fault" IgnorePlatformOnly IgnoreClass = "platform-only" )
type MissAdmission ¶ added in v0.40.0
type MissAdmission struct {
Identity Identity `json:"identity"`
Reason string `json:"reason"`
MovedFrom *Identity `json:"movedFrom,omitempty"`
}
MissAdmission records why an exact raw miss may remain in the baseline.
type PlatformDirective ¶ added in v0.40.0
type PlatformDirective struct {
Directive Directive `json:"directive"`
Platforms []string `json:"platforms"`
Class IgnoreClass `json:"class"`
Evidence string `json:"evidence"`
}
PlatformDirective records a source directive that the host profile cannot measure.
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.
type Review ¶ added in v0.40.0
type Review struct {
Misses []MissAdmission `json:"misses"`
Directives []DirectiveAdmission `json:"directives"`
PlatformDirectives []PlatformDirective `json:"platformDirectives"`
EquivalentMutants []EquivalentMutant `json:"equivalentMutants"`
}
Review supplies independently reviewed evidence for baseline changes.
func LoadReview ¶ added in v0.40.0
LoadReview loads strict review evidence.
type Selector ¶ added in v0.40.0
type Selector struct {
Name string `json:"name"`
Roots []string `json:"roots"`
Misses []Identity `json:"misses"`
}
Selector is one critical path set derived from the whole-module profile.
type SelectorBaseline ¶ added in v0.40.0
type SelectorBaseline struct {
Name string `json:"name"`
Roots []string `json:"roots"`
Misses []Identity `json:"misses"`
}
SelectorBaseline is the canonical baseline view of a critical selector.