Documentation
¶
Index ¶
- func CanCollect() bool
- func CanCollectPerTestCoverage() bool
- func CanComputeCoverageProfile() bool
- func CleanupRuntimeCoverageSnapshot()
- func ConfigureBackfill(input BackfillInput)
- func FinalizeProcessCoverageProfiles() (bool, error)
- func GetCoverage() float64
- func InitializeCoverage(m *testing.M, uploadEnabled bool)
- func MergeProcessCoverageProfile(childPath string) error
- func ResetForTesting()
- func RuntimeCoverageSnapshot() (*runtimeCoverageSnapshot, error)
- func SubmitProcessTestCoverage(sessionID, suiteID, testID uint64, files []ProcessTestCoverageFile)
- func WriteLCOVReport(w io.Writer) error
- func WriteLCOVReportFromProfile(profilePath string, w io.Writer) error
- type BackfillInput
- type BackfillResult
- type ProcessCoverageProfile
- type ProcessTestCoverage
- type ProcessTestCoverageFile
- type TestCoverage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanCollectPerTestCoverage ¶ added in v2.10.0
func CanCollectPerTestCoverage() bool
CanCollectPerTestCoverage returns whether per-test coverage upload can run.
func CanComputeCoverageProfile ¶ added in v2.10.0
func CanComputeCoverageProfile() bool
CanComputeCoverageProfile returns whether a runtime coverprofile can be produced.
func CleanupRuntimeCoverageSnapshot ¶ added in v2.10.0
func CleanupRuntimeCoverageSnapshot()
CleanupRuntimeCoverageSnapshot removes a generated temp snapshot once.
func ConfigureBackfill ¶ added in v2.10.0
func ConfigureBackfill(input BackfillInput)
ConfigureBackfill stores backend aggregate coverage for the finalizer.
func FinalizeProcessCoverageProfiles ¶
FinalizeProcessCoverageProfiles merges all isolated coverage once, after testing.M.Run has produced the parent's final profile. This also updates an explicit -coverprofile because RuntimeCoverageSnapshot selects that file.
func GetCoverage ¶
func GetCoverage() float64
GetCoverage returns the total coverage percentage for the test package
func InitializeCoverage ¶
InitializeCoverage initializes the runtime coverage.
func MergeProcessCoverageProfile ¶
MergeProcessCoverageProfile validates and accumulates an isolated process profile. The parent runtime profile is not touched until M.Run has finished; taking its snapshot while tests are still running would lose later coverage.
func ResetForTesting ¶ added in v2.10.0
func ResetForTesting()
ResetForTesting clears package globals used by coverage tests.
func RuntimeCoverageSnapshot ¶ added in v2.10.0
func RuntimeCoverageSnapshot() (*runtimeCoverageSnapshot, error)
RuntimeCoverageSnapshot returns the single coverage profile snapshot used for final coverage calculation and ITR backfill.
func SubmitProcessTestCoverage ¶
func SubmitProcessTestCoverage(sessionID, suiteID, testID uint64, files []ProcessTestCoverageFile)
SubmitProcessTestCoverage attaches child-produced coverage to the parent test event identifiers and queues it on the existing coverage writer.
func WriteLCOVReport ¶ added in v2.10.0
WriteLCOVReport writes an LCOV report from the current runtime coverage snapshot.
Types ¶
type BackfillInput ¶ added in v2.10.0
type BackfillInput struct {
BackendCoverage map[string]*filebitmap.FileBitmap
ActualSkips int
}
BackfillInput configures backend aggregate coverage that can repair the process-local coverage profile after ITR skips have been applied.
type BackfillResult ¶ added in v2.10.0
type BackfillResult struct {
Applied bool
Reason string
Coverage float64
ProfilePath string
MatchedFiles int
UnmatchedBackendFiles int
MatchedBlocks int
UpdatedBlocks int
}
BackfillResult describes one idempotent coverage backfill finalization.
func FinalizeBackfill ¶ added in v2.10.0
func FinalizeBackfill() BackfillResult
FinalizeBackfill applies backend coverage to the runtime snapshot once.
func PreflightBackfill ¶ added in v2.10.0
func PreflightBackfill(input BackfillInput) BackfillResult
PreflightBackfill validates that runtime coverage can later be backfilled. Path matching is deferred to FinalizeBackfill because producing a coverage profile before testing.M.Run completes mutates Go's runtime coverage state.
type ProcessCoverageProfile ¶
type ProcessCoverageProfile struct {
// contains filtered or unexported fields
}
ProcessCoverageProfile owns the aggregate coverage snapshot captured before an isolated workload starts.
func BeginProcessCoverageProfile ¶
func BeginProcessCoverageProfile() (*ProcessCoverageProfile, error)
BeginProcessCoverageProfile captures the aggregate coverage present before an isolated workload starts.
func (*ProcessCoverageProfile) Pause ¶
func (p *ProcessCoverageProfile) Pause() error
Pause finishes the active aggregate coverage segment. A later Resume starts a new baseline so coverage collected while the workload is suspended is excluded.
func (*ProcessCoverageProfile) Resume ¶
func (p *ProcessCoverageProfile) Resume() error
Resume starts another aggregate coverage segment after a suspended workload resumes.
func (*ProcessCoverageProfile) WriteDelta ¶
func (p *ProcessCoverageProfile) WriteDelta(path string) error
WriteDelta writes the aggregate coverage collected across active segments.
type ProcessTestCoverage ¶
type ProcessTestCoverage struct {
// contains filtered or unexported fields
}
ProcessTestCoverage owns one runtime-coverage delta.
func BeginProcessTestCoverage ¶
func BeginProcessTestCoverage(testFile string) *ProcessTestCoverage
BeginProcessTestCoverage starts a coverage delta. Because Go's runtime coverage counters are process-global, callers must serialize covered test bodies or discard deltas whose bodies overlap.
func (*ProcessTestCoverage) Finish ¶
func (c *ProcessTestCoverage) Finish() []ProcessTestCoverageFile
Finish returns the coverage delta and releases the collector resources.
func (*ProcessTestCoverage) Pause ¶
func (c *ProcessTestCoverage) Pause()
Pause finishes the active coverage segment. A later Resume starts a new baseline so coverage collected while the test is suspended is excluded.
func (*ProcessTestCoverage) Resume ¶
func (c *ProcessTestCoverage) Resume()
Resume starts another coverage segment after a suspended test resumes.
type ProcessTestCoverageFile ¶
type ProcessTestCoverageFile struct {
Name string `json:"name"`
Bitmap []byte `json:"bitmap,omitempty"`
}
ProcessTestCoverageFile is a serializable per-test coverage delta produced by an isolated test process.
type TestCoverage ¶
type TestCoverage interface {
// CollectCoverageBeforeTestExecution collects coverage before test execution.
CollectCoverageBeforeTestExecution()
// CollectCoverageAfterTestExecution collects coverage after test execution.
CollectCoverageAfterTestExecution()
}
TestCoverage is the interface for collecting test coverage.
func NewTestCoverage ¶
func NewTestCoverage(sessionID, moduleID, suiteID, testID uint64, testFile string) TestCoverage
NewTestCoverage creates a new test coverage.