Commit b6544a2a authored by Agniva De Sarker's avatar Agniva De Sarker Committed by Agniva De Sarker

testing/cover: improve message when a package has no statements

Fixes #25492

Change-Id: Ic1496857524dad0c0a77f3bb80fa084c9bf00aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/155777
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRob Pike <r@golang.org>
parent 0ff9df6b
......@@ -2612,6 +2612,14 @@ func TestCoverageDepLoop(t *testing.T) {
tg.grepStdout("coverage: 100.0% of statements", "expected 100.0% coverage")
}
func TestCoverageNoStatements(t *testing.T) {
tooSlow(t)
tg := testgo(t)
defer tg.cleanup()
tg.run("test", "-cover", "./testdata/testcover/pkg4")
tg.grepStdout("[no statements]", "expected [no statements] for pkg4")
}
func TestCoverageImportMainLoop(t *testing.T) {
skipIfGccgo(t, "gccgo has no cover tool")
tg := testgo(t)
......
package pkg4
type T struct {
X bool
}
package pkg4
import (
"testing"
)
func TestT(t *testing.T) {
_ = T{}
}
......@@ -109,7 +109,8 @@ func coverReport() {
}
}
if total == 0 {
total = 1
fmt.Println("coverage: [no statements]")
return
}
fmt.Printf("coverage: %.1f%% of statements%s\n", 100*float64(active)/float64(total), cover.CoveredPackages)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment