cover

package
v0.0.0-...-a29b1dd Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: Apache-2.0, BSD-3-Clause Imports: 11 Imported by: 0

README

Source: https://go.googlesource.com/tools/+/master/cmd/cover/func.go
Source: https://go.googlesource.com/tools/+/master/cover/profile.go
Revision: ac303766f5f240c1796eeea3dc9bf34f1261aa35
License: BSD

Note that starting with 1.5, go tool cover lives in the standard repository but
we inline it here so we can skip significant disk I/O.

Documentation

Overview

Package cover provides support for parsing coverage profiles generated by "go test -coverprofile=cover.out".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boundary

type Boundary struct {
	Offset int     // Location as a byte offset in the source file.
	Start  bool    // Is this the start of a block?
	Count  int     // Event count from the cover profile.
	Norm   float64 // Count normalized to [0..1].
}

Boundary represents the position in a source file of the beginning or end of a block as reported by the coverage profile. In HTML mode, it will correspond to the opening or closing of a <span> tag and will be used to colorize the source

type FuncExtent

type FuncExtent struct {
	FileName  string
	FuncName  string
	StartLine int
	StartCol  int
	EndLine   int
	EndCol    int
}

FuncExtent is the extent of a functions.

func FindFuncs

func FindFuncs(fileName string, r io.Reader) ([]*FuncExtent, error)

FindFuncs returns all the functions defined by a Go source file.

func (*FuncExtent) Coverage

func (f *FuncExtent) Coverage(profile *Profile) (int, []int)

Coverage returns number of lines covered and the slice of lines missing.

type IsIgnored

type IsIgnored interface {
	IsIgnored(p string) bool
}

IsIgnored is an interface to ignore files. MARUEL

type Profile

type Profile struct {
	FileName string
	Mode     string
	Blocks   []ProfileBlock
}

Profile represents the profiling data for a specific file.

func ParseProfiles

func ParseProfiles(ignore IsIgnored, r io.Reader) ([]*Profile, error)

ParseProfiles parses profile data in the specified file and returns a Profile for each source file described therein.

func (*Profile) Boundaries

func (p *Profile) Boundaries(src []byte) (boundaries []Boundary)

Boundaries returns a Profile as a set of Boundary objects within the provided src.

type ProfileBlock

type ProfileBlock struct {
	StartLine, StartCol int
	EndLine, EndCol     int
	NumStmt, Count      int
}

ProfileBlock represents a single block of profiling data.

Jump to

Keyboard shortcuts

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