coverage

package
v0.0.0-...-ccd9fd3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTestOptions = &TestOptions{
	Flags:    nil,
	Packages: []string{"."},
	Excludes: nil,
}
View Source
var ErrNoPackages = errors.New("no packages specified")

Functions

func Module

func Module(ctx diag.Context) module

func Percent

func Percent(c EachPather) float64

func Report

func Report(c PathDetailer) string

Report creates a multi-line report with details of each package's coverage on a line. If there is more than one package, a total package '.' will be added.

func ReportMD

func ReportMD(c PathDetailer) string

ReportMD creates a multi-line report with details of each package's coverage on a line. If there is more than one package, a total package '.' will be added.

func ReportMDTo

func ReportMDTo(w io.Writer, c PathDetailer)

ReportTo writes Report to a specified Writer.

func ReportTo

func ReportTo(w io.Writer, c PathDetailer)

ReportTo writes Report to a specified Writer.

Types

type BaseDetailer

type BaseDetailer interface {
	// Paths return a sorted list of known packages
	Paths() []string
	// BaseDetail returns statement counts for the requested package
	BaseDetail(pkg string) Counts
}

type ChangeDetailer

type ChangeDetailer interface {
	PathDetailer
	BaseDetailer
}

func Diff

func Diff(log diag.Interface, old, new EachPather) ChangeDetailer

type Counts

type Counts struct {
	Total       int
	Covered     int
	IsAggregate bool
}

type EachFiler

type EachFiler interface {
	// EachFile calls back at least once for each file.
	// Counts and coverage for the file should be summed.
	EachFile(func(path string, count int, covered int))
}

type EachModuler

type EachModuler interface {
	// EachModuler calls back at least once for each module.
	// Counts and coverage for the package should be summed.
	EachModule(func(path string, count int, covered int))
}

type EachPackager

type EachPackager interface {
	// EachPackage calls back at least once for each package.
	// Counts and coverage for the package should be summed.
	EachPackage(func(path string, count int, covered int))
}

type EachPather

type EachPather interface {
	// EachPath calls back exactly once for each tracked path.
	// Unlike the other Each* methods, this is at the 'native' granularity
	// for the underlying storage.
	EachPath(func(path string, count int, covered int))
	Grouping() Grouping
}

type EachStatementer

type EachStatementer interface {
	// EachStatement calls back once for each statement.
	EachStatement(func(path, pos string, count int, covered int))
}

type FileData

type FileData map[string]StmtCount

func ByFiles

func ByFiles(log diag.Interface, stmts EachStatementer) FileData

func CollectFiles

func CollectFiles(ctx diag.Context, options *TestOptions) (FileData, error)

func (FileData) Detail

func (fd FileData) Detail(path string) Counts

func (FileData) EachFile

func (fd FileData) EachFile(fn func(path string, count int, covered int))

func (FileData) EachModule

func (fd FileData) EachModule(fn func(path string, count int, covered int))

func (FileData) EachPackage

func (fd FileData) EachPackage(fn func(path string, count int, covered int))

func (FileData) EachPath

func (fd FileData) EachPath(fn func(path string, count int, covered int))

func (FileData) Grouping

func (FileData) Grouping() Grouping

func (FileData) Paths

func (fd FileData) Paths() []string

type FileDelta

type FileDelta struct{ PathDelta }

func (FileDelta) BaseDetail

func (fd FileDelta) BaseDetail(p string) Counts

func (FileDelta) Detail

func (fd FileDelta) Detail(p string) Counts

func (FileDelta) Grouping

func (FileDelta) Grouping() Grouping

type Grouping

type Grouping int
const (
	UnknownGrouping Grouping = iota
	StatementGrouping
	FileGrouping
	PackageGrouping
	RootGrouping
	ModuleGrouping
)

func (Grouping) String

func (g Grouping) String() string

type ModuleData

type ModuleData struct{ PathData }

func ByModule

func ByModule(log diag.Interface, pkgs EachPackager) ModuleData

func (ModuleData) Detail

func (md ModuleData) Detail(p string) Counts

func (ModuleData) Grouping

func (ModuleData) Grouping() Grouping

type ModuleDelta

type ModuleDelta struct{ PathDelta }

func (ModuleDelta) BaseDetail

func (md ModuleDelta) BaseDetail(p string) Counts

func (ModuleDelta) Detail

func (md ModuleDelta) Detail(p string) Counts

func (ModuleDelta) Grouping

func (ModuleDelta) Grouping() Grouping

type PackageData

type PackageData struct{ PathData }

func ByPackage

func ByPackage(log diag.Interface, files EachFiler) PackageData

func (PackageData) Detail

func (pd PackageData) Detail(p string) Counts

func (PackageData) Grouping

func (PackageData) Grouping() Grouping

type PackageDelta

type PackageDelta struct{ PathDelta }

func (PackageDelta) BaseDetail

func (pd PackageDelta) BaseDetail(p string) Counts

func (PackageDelta) Detail

func (pd PackageDelta) Detail(p string) Counts

func (PackageDelta) Grouping

func (PackageDelta) Grouping() Grouping

type PathData

type PathData map[string]StmtCount

func (PathData) Detail

func (pd PathData) Detail(path string, agg bool) Counts

func (PathData) EachModule

func (pd PathData) EachModule(fn func(path string, count int, covered int))

func (PathData) EachPackage

func (pd PathData) EachPackage(fn func(path string, count int, covered int))

func (PathData) EachPath

func (pd PathData) EachPath(fn func(path string, count int, covered int))

func (PathData) Paths

func (pd PathData) Paths() []string

type PathDelta

type PathDelta map[string]StmtDelta

func (PathDelta) BaseDetail

func (pd PathDelta) BaseDetail(path string, agg bool) Counts

func (PathDelta) Detail

func (pd PathDelta) Detail(path string, agg bool) Counts

func (PathDelta) Paths

func (pd PathDelta) Paths() []string

type PathDetailer

type PathDetailer interface {
	// Grouping returns a description of the grouping level
	Grouping() Grouping
	// Paths return a sorted list of known paths
	Paths() []string
	// Detail returns statement counts for the requested package
	Detail(pkg string) Counts
}

type RootData

type RootData struct{ PathData }

func ByRoot

func ByRoot(log diag.Interface, pkgs EachPackager) RootData

func (RootData) Detail

func (rd RootData) Detail(p string) Counts

func (RootData) Grouping

func (RootData) Grouping() Grouping

type RootDelta

type RootDelta struct{ PathDelta }

func (RootDelta) BaseDetail

func (rd RootDelta) BaseDetail(p string) Counts

func (RootDelta) Detail

func (rd RootDelta) Detail(p string) Counts

func (RootDelta) Grouping

func (RootDelta) Grouping() Grouping

type StatementData

type StatementData map[stmt]bool // StatementData skips EachPath as EachStatement is not unique per file.

StatementData records all statements (including location data) and covered status

func CollectStatements

func CollectStatements(ctx diag.Context, options *TestOptions) (StatementData, error)

func LoadProfile

func LoadProfile(ctx diag.Context, prof string, options *TestOptions) (StatementData, error)

LoadProfile loads statement coverage from a coverprofile file.

func ReadProfile

func ReadProfile(ctx diag.Context, r io.Reader, options *TestOptions) (StatementData, error)

ReadProfile loads statement coverage from a Reader.

func (StatementData) EachFile

func (sd StatementData) EachFile(fn func(path string, count int, covered int))

func (StatementData) EachModule

func (sd StatementData) EachModule(fn func(path string, count int, covered int))

func (StatementData) EachPackage

func (sd StatementData) EachPackage(fn func(path string, count int, covered int))

func (StatementData) EachStatement

func (sd StatementData) EachStatement(fn func(path, pos string, count int, covered int))

type StmtCount

type StmtCount struct{ Count, Covered int }

type StmtDelta

type StmtDelta struct{ BaseCount, BaseCovered, HeadCount, HeadCovered int }

type TestOptions

type TestOptions struct {
	CoverProfile   string
	Flags          []string
	Packages       []string
	Excludes       []string
	Stdout, Stderr io.Writer
}

Jump to

Keyboard shortcuts

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