mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/coverage: improve unit tests
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>
This commit is contained in:
parent
690851ee3e
commit
9d6dc32edd
3 changed files with 73 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ import (
|
|||
"internal/coverage/decodecounter"
|
||||
"internal/coverage/decodemeta"
|
||||
"internal/coverage/pods"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
|
@ -21,6 +22,12 @@ import (
|
|||
// intended to be used other than internally by the Go command's
|
||||
// generated code.
|
||||
func processCoverTestDir(dir string, cfile string, cm string, cpkg string) error {
|
||||
return processCoverTestDirInternal(dir, cfile, cm, cpkg, os.Stdout)
|
||||
}
|
||||
|
||||
// processCoverTestDirInternal is an io.Writer version of processCoverTestDir,
|
||||
// exposed for unit testing.
|
||||
func processCoverTestDirInternal(dir string, cfile string, cm string, cpkg string, w io.Writer) error {
|
||||
cmode := coverage.ParseCounterMode(cm)
|
||||
if cmode == coverage.CtrModeInvalid {
|
||||
return fmt.Errorf("invalid counter mode %q", cm)
|
||||
|
|
@ -80,7 +87,7 @@ func processCoverTestDir(dir string, cfile string, cm string, cpkg string) error
|
|||
}
|
||||
|
||||
// Emit percent.
|
||||
if err := ts.cf.EmitPercent(os.Stdout, cpkg, true); err != nil {
|
||||
if err := ts.cf.EmitPercent(w, cpkg, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue