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>
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)
--- /dev/null
+package pkg4
+
+type T struct {
+ X bool
+}
--- /dev/null
+package pkg4
+
+import (
+ "testing"
+)
+
+func TestT(t *testing.T) {
+ _ = T{}
+}
}
}
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)
}