-
-
Notifications
You must be signed in to change notification settings - Fork 136
Closed
Description
Hi, I use this branch https://github.com/gaocegege/ormb/tree/goveralls-bug to run goveralls and find that some test coverage is not reported to coveralls.
I find that the logic here has errors: https://github.com/mattn/goveralls/blob/master/gocover.go#L33
I do not think we can assume that each profile has the same sorted FileName and Blocks. I think we need to add more checks for it.
In my case, the test coverage for one profile does not have the same order with others, then it is ignored since we only use the order in head to check it.
Here is a simple fix https://github.com/kleveross/goveralls/pull/1/files:
// mergeProfs merges profiles for same target packages.
// It assumes each profiles have same sorted FileName and Blocks.
func mergeProfs(pfss [][]*cover.Profile) []*cover.Profile {
// skip empty profiles ([no test files])
for i := 0; i < len(pfss); i++ {
if len(pfss[i]) > 0 {
pfss = pfss[i:]
break
}
}
if len(pfss) == 0 {
return nil
} else if len(pfss) == 1 {
return pfss[0]
}
head, rest := pfss[0], pfss[1:]
ret := make([]*cover.Profile, 0, len(head))
for _, profile := range head {
for _, ps := range rest {
// find profiles
if len(ps) == 0 {
continue
} else {
for _, p := range ps {
if p.FileName == profile.FileName {
profile.Blocks = mergeProfBlocks(profile.Blocks, p.Blocks)
break
}
}
continue
}
}
ret = append(ret, profile)
}
return ret
}Metadata
Metadata
Assignees
Labels
No labels