testcoverage

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrThresholdNotInRange         = fmt.Errorf("threshold must be in range [0 - 100]")
	ErrCoverageProfileNotSpecified = fmt.Errorf("coverage profile file not specified")
)

Functions

func ConfigFromFile

func ConfigFromFile(cfg *Config, filename string) error

func ReportForGithubAction

func ReportForGithubAction(w io.Writer, result AnalyzeResult, thr Threshold)

func ReportForHuman

func ReportForHuman(w io.Writer, result AnalyzeResult, thr Threshold)

func SetGithubActionOutput

func SetGithubActionOutput(result AnalyzeResult) error

Types

type AnalyzeResult

type AnalyzeResult struct {
	FilesBelowThreshold    []CoverageStats
	PackagesBelowThreshold []CoverageStats
	MeetsTotalCoverage     bool
	TotalCoverage          int
}

func Analyze

func Analyze(cfg Config, coverageStats []CoverageStats) AnalyzeResult

func Check

func Check(w io.Writer, cfg Config) (AnalyzeResult, error)

func (*AnalyzeResult) Pass

func (r *AnalyzeResult) Pass() bool

type Config

type Config struct {
	Profile            string    `yaml:"profile"`
	LocalPrefix        string    `yaml:"local-prefix"`
	Threshold          Threshold `yaml:"threshold"`
	GithubActionOutput bool      `yaml:"github-action-output"`
}

func (Config) Validate

func (c Config) Validate() error

type CoverageStats

type CoverageStats struct {
	Name    string
	Total   int64
	Covered int64
}

func GenerateCoverageStats

func GenerateCoverageStats(cfg Config) ([]CoverageStats, error)

func (*CoverageStats) CoveredPercentage

func (s *CoverageStats) CoveredPercentage() int

type FuncExtent

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

FuncExtent describes a function's extent in the source by file and position.

type FuncVisitor

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

FuncVisitor implements the visitor that builds the function position list for a file.

func (*FuncVisitor) Visit

func (v *FuncVisitor) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface.

type Threshold

type Threshold struct {
	File    int `yaml:"file"`
	Package int `yaml:"package"`
	Total   int `yaml:"total"`
}

Jump to

Keyboard shortcuts

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