Documentation ¶
Overview ¶
package report generates the diff coverage report for current commit and compared branch.
Index ¶
Constants ¶
const (
// CodeLanguage represents the language style for report.
CodeLanguage = "go"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllInformation ¶
type CoverageProfile ¶
type CoverageProfile struct { // FileName indicates which file belongs to this coverage profile. FileName string // TotalLines indicates total lines of this coverage profile. TotalLines int // CoveredLines indicates covered lines of this coverage profile. CoveredLines int // CoveragePercent indicates the diff coverage percent for this file. TotalViolationLines []int // ViolationSections indicates the violation sections that miss full coverage. ViolationSections []*ViolationSection // CodeSnippet represents the output of the ViolationSections, it's calculated from ViolationSections. CodeSnippet []template.HTML }
CoverageProfile represents the test coverage information for a file.
type CoverageTree ¶
type CoverageTree interface { // FindOrCreate returns the leaf node that represents the source file (go) if found, // otherwise, it will creates the all the nodes along the path to the leaf, and finally return it. FindOrCreate(file string) *TreeNode Find(pkgPath string) *TreeNode CollectCoverageData() All() []*AllInformation Statistics() *AllInformation }
func NewCoverageTree ¶
func NewCoverageTree(hostpath string) CoverageTree
type DiffCoverage ¶
type DiffCoverage interface {
GenerateDiffCoverage() (*Statistics, error)
}
DiffCoverage expose the diff coverage statistics
func NewDiffCoverage ¶
type FullCoverage ¶
type FullCoverage interface {
BuildFullCoverageTree() []*AllInformation
}
func NewFullCoverage ¶
type ReportGenerator ¶
type ReportGenerator interface {
GenerateReport() error
}
ReportGenerator represents the feature that generate coverage report.
func NewReportGenerator ¶
func NewReportGenerator( statistics *Statistics, codeStyle string, outputPath string, reportName string, ) ReportGenerator
NewReportGenerator creates a html report generator to generate html coverage report. We will use https://pygments.org/docs/styles to style the output, and use // https://github.com/alecthomas/chroma to help to generate code snippets.
type Statistics ¶
type Statistics struct { // ComparedBranch the branch that diff compared with. ComparedBranch string // TotalLines represents the total lines that count for coverage. TotalLines int // TotalCoveredLines indicates total covered lines that count for coverage. TotalCoveredLines int // TotalViolationLines represents all the lines that miss test coverage. TotalViolationLines int // TotalCoveragePercent represents the coverage percent for current diff. TotalCoveragePercent float64 // CoverageProfile represents the coverage profile for a specific file. CoverageProfile []*CoverageProfile }
Statistics represents the total diff coverage for the HEAD commit. It contains the total coverage and possible coverage profile.
type TreeNode ¶
type TreeNode struct { Name string // name TotalLines int64 // total lines account for coverage TotalCoveredLines int64 // covered lines account for coverage TotalViolationLines int64 // violation lines that not covered for coverage CoverageProfile *CoverageProfile Nodes map[string]*TreeNode // sub nodes that store in map // contains filtered or unexported fields }
TreeNode represents the node of multi branches tree. Each node contains the basic coverage information, includes covered lines count, totol lines count and vioaltion lines count. Each internal node has one or many sub node, which is stored in a map, and can be retrieved by node name. For the leaf node, it does not have sub node.
func NewTreeNode ¶
type ViolationSection ¶
type ViolationSection struct { // ViolationLines indicates which line miss the coverage. ViolationLines []int // StartLine indicates the start line of the section. StartLine int // EndLine indicates the end line of the section. EndLine int // Contents contains [StartLine..EndLine] lines from the source file. Contents []string }
ViolationSection represents a portion of the change that miss unit test coverage.