Documentation
¶
Overview ¶
Package covergate is the exact statement-coverage gate. It reads a Go cover profile and passes only when every statement in it was executed.
The gate has no threshold to configure: it compares the number of covered statements with the total number of statements, so 99.99% fails. There is no flag, environment variable or input that lowers the bar.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Missing ¶
Missing returns a message for each Go file with a build constraint, for each test file that declares a TestMain, and for each package that has statements and is absent from the profile or contributes no statements to it. perPackage is the statement count of each package path in the profile.
func Run ¶
Run checks the profile named by args, which must be exactly one path. It returns the process exit code: 0 when every statement is covered and every package of the module that has statements is in the profile with some, 1 when not, 2 on a usage or I/O error. Anything else on the command line, including a flag, is a usage error: the gate takes no options.
Types ¶
type Open ¶
type Open func(name string) (io.ReadCloser, error)
Open opens the named cover profile. Run takes it as a parameter so tests can supply an in-memory profile.
type Package ¶
type Package struct {
Path string
HasStatements bool
TestMains []string // the test files that declare a TestMain
Constraints []string // a message for each build constraint of a Go file
}
Package is a package of the module, as `go list ./...` would list it: its import path, and whether its non-test Go files hold any statement. A package with statements must appear in the cover profile with a statement count above zero: a test binary whose TestMain exits 0 before it runs, or a package the profile was written without, must not make the package vanish from the count.
type Packages ¶
Packages lists the packages of the module. Run takes it as a parameter so that tests can supply a fixed list.
func OSPackages ¶
OSPackages lists the packages of the module rooted at root (the directory of its go.mod) the way `go list ./...` does, without running it: every directory with Go files for this platform, except those whose name begins with "." or "_", testdata directories, and nested modules. A directory with only test files is a package without statements.
type Result ¶
Result is the statement count of a cover profile.
func Parse ¶
Parse reads a cover profile. A block listed more than once (for example by several test binaries) counts once, and counts as covered if any listing covered it.
func ParseByPackage ¶
ParseByPackage is Parse that also returns the number of statements the profile holds for each package, named by import path (the directory of a block's file).