coverage

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	StartLine int
	StartCol  int
	EndLine   int
	EndCol    int
}

Block holds the start and end coordinates of a section of a source file covered by tests.

type Coverage

type Coverage struct {
	// contains filtered or unexported fields
}

Coverage is responsible for executing a Go test with coverage via the Run() method, then parsing the result coverage report file.

func New

func New(workdir string, mod gomodule.GoModule, opts ...Option) *Coverage

New instantiates a Coverage element using exec.Command as execContext, actually running the command on the OS.

func NewWithCmd

func NewWithCmd(cmdContext execContext, workdir string, mod gomodule.GoModule, opts ...Option) *Coverage

NewWithCmd instantiates a Coverage element given a custom execContext.

func (*Coverage) Run

func (c *Coverage) Run() (Result, error)

Run executes the coverage command and parses the results, returning a *Profile object. Before executing the coverage, it downloads the go modules in a separate step. This is done to avoid that the download phase impacts the execution time which is later used as timeout for the mutant testing execution.

type Option

type Option func(c *Coverage) *Coverage

Option for the Coverage initialization.

type Profile

type Profile map[string][]Block

Profile is implemented as a map holding a slice of Block per each filename.

func (Profile) IsCovered

func (p Profile) IsCovered(pos token.Position) bool

IsCovered checks if the given token.Position is covered by the coverage Profile.

type Result

type Result struct {
	Profile Profile
	Elapsed time.Duration
}

Result contains the Profile generated by the coverage and the time it took to generate the coverage report.

Jump to

Keyboard shortcuts

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