mirror of
https://github.com/golang/go
synced 2024-11-23 15:20:03 -07:00
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: Rob Pike <r@golang.org>
This commit is contained in:
parent
0ff9df6b53
commit
b6544a2a87
@ -2612,6 +2612,14 @@ func TestCoverageDepLoop(t *testing.T) {
|
|||||||
tg.grepStdout("coverage: 100.0% of statements", "expected 100.0% coverage")
|
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) {
|
func TestCoverageImportMainLoop(t *testing.T) {
|
||||||
skipIfGccgo(t, "gccgo has no cover tool")
|
skipIfGccgo(t, "gccgo has no cover tool")
|
||||||
tg := testgo(t)
|
tg := testgo(t)
|
||||||
|
5
src/cmd/go/testdata/testcover/pkg4/a.go
vendored
Normal file
5
src/cmd/go/testdata/testcover/pkg4/a.go
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package pkg4
|
||||||
|
|
||||||
|
type T struct {
|
||||||
|
X bool
|
||||||
|
}
|
9
src/cmd/go/testdata/testcover/pkg4/a_test.go
vendored
Normal file
9
src/cmd/go/testdata/testcover/pkg4/a_test.go
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package pkg4
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestT(t *testing.T) {
|
||||||
|
_ = T{}
|
||||||
|
}
|
@ -109,7 +109,8 @@ func coverReport() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if total == 0 {
|
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)
|
fmt.Printf("coverage: %.1f%% of statements%s\n", 100*float64(active)/float64(total), cover.CoveredPackages)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user