]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: change to use struct in go test -cover
authorRob Pike <r@golang.org>
Thu, 13 Jun 2013 20:12:58 +0000 (13:12 -0700)
committerRob Pike <r@golang.org>
Thu, 13 Jun 2013 20:12:58 +0000 (13:12 -0700)
Go tool half of https://golang.org/cl/10271044

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/10272043

src/cmd/go/build.go
src/cmd/go/pkg.go
src/cmd/go/test.go

index e8f390483c8dd1366a5864ad02a775ed99b1aa3e..213489a1a5cb490aa4f3c78f1b24f503b0118378 100644 (file)
@@ -798,7 +798,7 @@ func (b *builder) build(a *action) (err error) {
                                continue
                        }
                        coverFile := filepath.Join(obj, file)
-                       if err := b.cover(a, coverFile, sourceFile, 0666, cover.Count, cover.Pos); err != nil {
+                       if err := b.cover(a, coverFile, sourceFile, 0666, cover.Var); err != nil {
                                return err
                        }
                        gofiles = append(gofiles, coverFile)
@@ -1110,13 +1110,12 @@ func (b *builder) copyFile(a *action, dst, src string, perm os.FileMode) error {
 }
 
 // cover runs, in effect,
-//     go tool cover -mode=b.coverMode -count="count" -pos="pos" -o dst.go src.go
-func (b *builder) cover(a *action, dst, src string, perm os.FileMode, count, pos string) error {
+//     go tool cover -mode=b.coverMode -var="varName" -o dst.go src.go
+func (b *builder) cover(a *action, dst, src string, perm os.FileMode, varName string) error {
        return b.run(a.objdir, "cover "+a.p.ImportPath, nil,
                tool("cover"),
                "-mode", a.p.coverMode,
-               "-count", count,
-               "-pos", pos,
+               "-var", varName,
                "-o", dst,
                src)
 }
index b399577a5a28de0913060eb2f85cc23f0f20f7a8..31e6da6d3451c71b48e55d37a566ddcfd804f583 100644 (file)
@@ -90,9 +90,8 @@ type Package struct {
 
 // CoverVar holds the name of the generated coverage variables targeting the named file.
 type CoverVar struct {
-       File  string // local file name
-       Count string // name of count array
-       Pos   string // name of position array
+       File string // local file name
+       Var  string // name of count struct
 }
 
 func (p *Package) copyBuild(pp *build.Package) {
index 11972cc8ccbd4a5ff2262252e417344e09dcbf1b..f33e56e0f3b5d0da156203991f5a478969b5dc1b 100644 (file)
@@ -682,9 +682,8 @@ func declareCoverVars(files ...string) map[string]*CoverVar {
        coverVars := make(map[string]*CoverVar)
        for _, file := range files {
                coverVars[file] = &CoverVar{
-                       File:  file,
-                       Count: fmt.Sprintf("GoCoverCount_%d", coverIndex),
-                       Pos:   fmt.Sprintf("GoCoverPos_%d", coverIndex),
+                       File: file,
+                       Var:  fmt.Sprintf("GoCover_%d", coverIndex),
                }
                coverIndex++
        }
@@ -988,7 +987,7 @@ var (
 
 func init() {
        {{range $file, $cover := .CoverVars}}
-       coverRegisterFile({{printf "%q" $file}}, _test.{{$cover.Count}}[:], _test.{{$cover.Pos}}[:]...)
+       coverRegisterFile({{printf "%q" $file}}, _test.{{$cover.Var}}.Count[:], _test.{{$cover.Var}}.Pos[:]...)
        {{end}}
 }