mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/coverage: avoid non-test coverage profiles in test report helper
When walking through the set of coverage data files generated from a "go test -cover" run, it's possible to encounter pods (clumps of data files) that were generated by a run from an instrumented Go tool (for example, cmd/compile). Add a guard to the test reporting code to ensure that it only processes files created by the currently running test. Fixes #57924. Change-Id: I1bb7dce88305e1088162e3cb1df628486ecee1c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/462756 Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
8bec956360
commit
cf70d37967
1 changed files with 9 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"internal/coverage/pods"
|
"internal/coverage/pods"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// processCoverTestDir is called (via a linknamed reference) from
|
// processCoverTestDir is called (via a linknamed reference) from
|
||||||
|
|
@ -80,7 +81,15 @@ func processCoverTestDirInternal(dir string, cfile string, cm string, cpkg strin
|
||||||
cf: cformat.NewFormatter(cmode),
|
cf: cformat.NewFormatter(cmode),
|
||||||
cmode: cmode,
|
cmode: cmode,
|
||||||
}
|
}
|
||||||
|
// Generate the expected hash string based on the final meta-data
|
||||||
|
// hash for this test, then look only for pods that refer to that
|
||||||
|
// hash (just in case there are multiple instrumented executables
|
||||||
|
// in play). See issue #57924 for more on this.
|
||||||
|
hashstring := fmt.Sprintf("%x", finalHash)
|
||||||
for _, p := range podlist {
|
for _, p := range podlist {
|
||||||
|
if !strings.Contains(p.MetaFile, hashstring) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if err := ts.processPod(p); err != nil {
|
if err := ts.processPod(p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue