uncover

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 19 Imported by: 0

README

uncover - Generate coverage reports from coverprofiles

Generates colorized coverage report to stdout of uncovered funcs. Source originates from the golang cover tool.

Quick start

Install

go install github.com/gregoryv/uncover/cmd/uncover@latest

In your project test with coverage and show result

go test -coverprofile /tmp/c.out
uncover /tmp/c.out [FuncName]

screenshot

Expect a minimum coverage

uncover -min 80.0 /tmp/c.out

Difference from go tool cover

The purpose of uncover is to focus your work on what remains to be verified. Thus it only shows uncovered lines. It also excludes unreachable code, ie. func _() which is sometimes used for compile checks.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OnlyShow string

Functions

func Report

func Report(profiles []*Profile, out io.Writer) (coverage float64, err error)

func Version

func Version() string

func Write

func Write(out io.Writer, profile *Profile, f *FuncExtent) error

Write reads the profile data from profile and generates colored vt100 output to stdout.

func WriteOutput

func WriteOutput(profiles []*Profile, out io.Writer) (coverage float64, err error)

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.
}

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 {
	Name string
	Decl *ast.FuncDecl

	Offset int
	End    int
	// 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 Profile

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

Profile represents the profiling data for a specific file.

func ParseProfiles

func ParseProfiles(fileName string) ([]*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.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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