本文整理汇总了Golang中core.BuildState.Coverage方法的典型用法代码示例。如果您正苦于以下问题:Golang BuildState.Coverage方法的具体用法?Golang BuildState.Coverage怎么用?Golang BuildState.Coverage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.BuildState
的用法示例。
在下文中一共展示了BuildState.Coverage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddOriginalTargetsToCoverage
// Adds empty coverage entries for any files covered by the original query that we
// haven't discovered through tests to the overall report.
// The coverage reports only contain information about files that were covered during
// tests, so it's important that we identify anything with zero coverage here.
// This is made trickier by attempting to reconcile coverage targets from languages like
// Java that don't preserve the original file structure, which requires a slightly fuzzy match.
func AddOriginalTargetsToCoverage(state *core.BuildState, includeAllFiles bool) {
// First we collect all the source files from all relevant targets
allFiles := map[string]bool{}
doneTargets := map[*core.BuildTarget]bool{}
// Track the set of packages the user ran tests from; we only show coverage metrics from them.
coveragePackages := map[string]bool{}
for _, label := range state.OriginalTargets {
coveragePackages[label.PackageName] = true
}
for _, label := range state.ExpandOriginalTargets() {
collectAllFiles(state, state.Graph.TargetOrDie(label), coveragePackages, allFiles, doneTargets, includeAllFiles)
}
// Now merge the recorded coverage so far into them
recordedCoverage := state.Coverage
state.Coverage = core.TestCoverage{Tests: recordedCoverage.Tests, Files: map[string][]core.LineCoverage{}}
mergeCoverage(state, recordedCoverage, coveragePackages, allFiles, includeAllFiles)
}