mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/coverage/pods: sort counter files first by origin, then name
This patch fixes a problem with the way pods (clumps of related coverage meta+counter data files) are collected, which was causing problems for "go tool covdata subtract". A subtract operation such as "go tool covdata subtract -i=dir1,dir2 -o=out" works by loading in all the counter data files from "dir1" before any of the data files from "dir2" are loaded. The sorting function in the pods code was sorting counter files for a given pod based purely on name, which meant that differences in process ID assignment could result in some files from "dir2" being presented before "dir1". The fix is to change the sorting compare function to prefer origin directory over filename. Fixes #60526. Change-Id: I2226ea675fc99666a9a28e6550d823bcdf2d6977 Reviewed-on: https://go-review.googlesource.com/c/go/+/499317 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
094c75219a
commit
0f91f92ee0
2 changed files with 19 additions and 16 deletions
|
|
@ -166,6 +166,9 @@ func collectPodsImpl(files []string, dirIndices []int, warn bool) []Pod {
|
|||
pods := make([]Pod, 0, len(mm))
|
||||
for _, p := range mm {
|
||||
sort.Slice(p.elements, func(i, j int) bool {
|
||||
if p.elements[i].origin != p.elements[j].origin {
|
||||
return p.elements[i].origin < p.elements[j].origin
|
||||
}
|
||||
return p.elements[i].file < p.elements[j].file
|
||||
})
|
||||
pod := Pod{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue