coverage

package
v2.11.0-dev.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanCollect

func CanCollect() bool

CanCollect returns whether coverage can be collected.

func CanCollectPerTestCoverage

func CanCollectPerTestCoverage() bool

CanCollectPerTestCoverage returns whether per-test coverage upload can run.

func CanComputeCoverageProfile

func CanComputeCoverageProfile() bool

CanComputeCoverageProfile returns whether a runtime coverprofile can be produced.

func CleanupRuntimeCoverageSnapshot

func CleanupRuntimeCoverageSnapshot()

CleanupRuntimeCoverageSnapshot removes a generated temp snapshot once.

func ConfigureBackfill

func ConfigureBackfill(input BackfillInput)

ConfigureBackfill stores backend aggregate coverage for the finalizer.

func GetCoverage

func GetCoverage() float64

GetCoverage returns the total coverage percentage for the test package

func InitializeCoverage

func InitializeCoverage(m *testing.M, uploadEnabled bool)

InitializeCoverage initializes the runtime coverage.

func ResetForTesting

func ResetForTesting()

ResetForTesting clears package globals used by coverage tests.

func RuntimeCoverageSnapshot

func RuntimeCoverageSnapshot() (*runtimeCoverageSnapshot, error)

RuntimeCoverageSnapshot returns the single coverage profile snapshot used for final coverage calculation and ITR backfill.

func WriteLCOVReport

func WriteLCOVReport(w io.Writer) error

WriteLCOVReport writes an LCOV report from the current runtime coverage snapshot.

func WriteLCOVReportFromProfile

func WriteLCOVReportFromProfile(profilePath string, w io.Writer) error

WriteLCOVReportFromProfile writes an LCOV report from a Go coverprofile.

Types

type BackfillInput

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

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

func FinalizeBackfill() BackfillResult

FinalizeBackfill applies backend coverage to the runtime snapshot once.

func PreflightBackfill

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 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL