1
0
mirror of https://github.com/golang/go synced 2024-11-23 00:40:08 -07:00

cmd/go, testing: remove redundant "for pkg" in coverage message

This is a transcript before this change. I've capitalized the text being removed.
Note that it is always near another line that already says fmt, marked with <<<

$ cd $GOROOT/src/pkg/fmt

$ go test -cover
PASS
coverage FOR FMT: 91.3% of statements
ok  	fmt	0.040s <<<

$ go test -coverpkg strconv
PASS
coverage FOR FMT: 64.9% of statements in strconv
ok  	fmt	0.039s <<<

$ go test -cover -c
$ ./fmt.test -test.covermode=set <<<
PASS
coverage FOR FMT: 91.3% of statements

$ go test -coverpkg strconv -c
$ ./fmt.test -test.covermode=set <<<
PASS
coverage FOR FMT: 64.9% of statements in strconv

That the summary printed by 'go test [options] fmt' is unchanged:

$ go test -cover fmt
ok  	fmt	0.040s	coverage: 91.3% of statements

$ go test -coverpkg strconv fmt
ok  	fmt	0.038s	coverage: 64.9% of statements in strconv

R=r
CC=gobot, golang-dev
https://golang.org/cl/10932045
This commit is contained in:
Russ Cox 2013-07-12 07:34:16 -04:00
parent 39b5f3a451
commit 56cd47b295
2 changed files with 2 additions and 2 deletions

View File

@ -937,7 +937,7 @@ func coveragePercentage(out []byte) string {
// The string looks like // The string looks like
// test coverage for encoding/binary: 79.9% of statements // test coverage for encoding/binary: 79.9% of statements
// Extract the piece from the percentage to the end of the line. // Extract the piece from the percentage to the end of the line.
re := regexp.MustCompile(`coverage for [^ ]+: (.*)\n`) re := regexp.MustCompile(`coverage: (.*)\n`)
matches := re.FindSubmatch(out) matches := re.FindSubmatch(out)
if matches == nil { if matches == nil {
// Probably running "go test -cover" not "go test -cover fmt". // Probably running "go test -cover" not "go test -cover fmt".

View File

@ -89,5 +89,5 @@ func coverReport() {
if total == 0 { if total == 0 {
total = 1 total = 1
} }
fmt.Printf("coverage for %s: %.1f%% of statements%s\n", testedPackage, 100*float64(active)/float64(total), coveredPackage) fmt.Printf("coverage: %.1f%% of statements%s\n", 100*float64(active)/float64(total), coveredPackage)
} }