mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/coverage: refactor EmitTextual in preparation for bugfix
Refactor cformat.EmitTextual to accept a package filter (list of packages to report). This is a no-op in terms of exposed coverage functionality, but we will need this feature in a subsequent patch. Updates #70244. Change-Id: I1e6bcbfb5e68187d4d69d54b667e97bc1fdfa2d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/627315 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
87023bb27f
commit
40b3c0e58a
4 changed files with 33 additions and 9 deletions
|
|
@ -47,8 +47,8 @@ func TestBasics(t *testing.T) {
|
|||
fm.AddUnit("lit.go", "f3", true, u, 0)
|
||||
}
|
||||
|
||||
var b1, b2, b3, b4 strings.Builder
|
||||
if err := fm.EmitTextual(&b1); err != nil {
|
||||
var b1, b2, b3, b4, b5 strings.Builder
|
||||
if err := fm.EmitTextual(nil, &b1); err != nil {
|
||||
t.Fatalf("EmitTextual returned %v", err)
|
||||
}
|
||||
wantText := strings.TrimSpace(`
|
||||
|
|
@ -64,6 +64,18 @@ lit.go:99.0,100.0 1 0`)
|
|||
t.Errorf("emit text: got:\n%s\nwant:\n%s\n", gotText, wantText)
|
||||
}
|
||||
|
||||
selected := []string{"my/pack2"}
|
||||
if err := fm.EmitTextual(selected, &b5); err != nil {
|
||||
t.Fatalf("EmitTextual returned %v", err)
|
||||
}
|
||||
wantText = strings.TrimSpace(`
|
||||
mode: atomic
|
||||
lit.go:99.0,100.0 1 0`)
|
||||
gotText = strings.TrimSpace(b5.String())
|
||||
if wantText != gotText {
|
||||
t.Errorf("emit text: got:\n%s\nwant:\n%s\n", gotText, wantText)
|
||||
}
|
||||
|
||||
// Percent output with no aggregation.
|
||||
noCoverPkg := ""
|
||||
if err := fm.EmitPercent(&b2, nil, noCoverPkg, false, false); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue