summaryrefslogtreecommitdiff
path: root/src/runtime/coverage/testsupport.go
Commit message (Collapse)AuthorAgeFilesLines
* runtime/coverage: avoid non-test coverage profiles in test report helperThan McIntosh2023-01-201-0/+9
| | | | | | | | | | | | | | | | | | 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>
* runtime/coverage: add missing file close in test support helperThan McIntosh2022-12-211-2/+13
| | | | | | | | | | | | | | | The processPod() helper (invoked by processCoverTestDir, which is in turn called by _testmain.go) was opening and reading counter data files, but never closing them. Add a call to close the files after they have been read. Fixes #57407. Change-Id: If9a489f92e4bab72c5b2df8697e14420a6f7b8f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/458835 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* runtime/coverage: improve unit testsThan McIntosh2022-09-291-1/+8
| | | | | | | | | Add a testpoint to cover support routines used to help implement "go test -cover". Change-Id: Ic28bf884a4e0d2c0a6d8fd04fc29c0c949227f21 Reviewed-on: https://go-review.googlesource.com/c/go/+/432315 Reviewed-by: Bryan Mills <bcmills@google.com>
* runtime/coverage: runtime routines to emit coverage dataThan McIntosh2022-09-281-0/+207
This patch fleshes out the runtime support for emitting coverage data at the end of a run of an instrumented binary. Data is emitted in the form of a pair of files, a meta-out-file and counter-data-outfile, each written to the dir GOCOVERDIR. The meta-out-file is emitted only if required; no need to emit again if an existing meta-data file with the same hash and length is present. Updates #51430. Change-Id: I59d20a4b8c05910c933ee29527972f8e401b1685 Reviewed-on: https://go-review.googlesource.com/c/go/+/355451 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com>