gocovparser

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCoverageData = errors.New("invalid coverage data - unable to parse")

ErrInvalidCoverageData happens when the data passed to gocovparser is either blank or not a coverage.out file content.

View Source
var FileParseGroup = ParseGroup{
	Name: "file",
	KeyFunc: func(filename string) string {
		return filename
	},
}

FileParseGroup returns each line as it's own key.

View Source
var PackageParseGroup = ParseGroup{
	Name: "package",
	KeyFunc: func(filename string) string {
		parts := strings.Split(filename, "/")

		return strings.Join(parts[:len(parts)-1], "/")
	},
}

PackageParseGroup parses the package from the coverage data and uses that as identifier.

View Source
var TotalParseGroup = ParseGroup{
	Name: "total",
	KeyFunc: func(string) string {
		return "total"
	},
}

TotalParseGroup uses 'total' as key to group all coverage data into a total.

Functions

This section is empty.

Types

type Coverage

type Coverage struct {
	FileName string
	Blocks   []cover.ProfileBlock

	Host  string
	Owner string
	Repo  string
	Path  string
}

Coverage line in a coverage.out file.

func FilterCoverage added in v0.3.0

func FilterCoverage(items []Coverage, filters ...Filter) ([]Coverage, error)

FilterCoverage using the specified filters.

func Parse

func Parse(coverageData string) ([]Coverage, error)

Parse a coverage result file contents from go tests.

type Filter added in v0.3.0

type Filter interface {
	FilterCoverage(Coverage) bool
}

Filter interface for filtering coverage by.

func FileExcludeFilter added in v0.3.0

func FileExcludeFilter(fileMatchRE string) Filter

FileExcludeFilter excludes any coverage that has a filename matching the specified regex.

func PackageExcludeFilter added in v0.3.0

func PackageExcludeFilter(packageName string) Filter

PackageExcludeFilter excludes any coverage that matches the packageName specified.

type ParseGroup

type ParseGroup struct {
	// Name of the parse group. Used to retrieve your parse data after grouping.
	Name string

	// KeyFunc that returns the grouping key to use based on the coverage line.
	KeyFunc func(string) string
}

ParseGroup to group coverage data by.

type ParseGroupResult

type ParseGroupResult map[string]map[string]float64

ParseGroupResult represents results of a Group Coverage operation.

func GroupCoverage

func GroupCoverage(items []Coverage, groups ...ParseGroup) (ParseGroupResult, error)

GroupCoverage in the specified groups.

Jump to

Keyboard shortcuts

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