Commit 7ccd505d authored by Sanjay Menakuru's avatar Sanjay Menakuru Committed by Andrew Gerrand

cmd/go: include test files in the files sent to gofmt, govet, and gofix

Also, add TestGoFiles to the go command's public api.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5505083
parent 12d48472
...@@ -36,11 +36,12 @@ being passed to the template is: ...@@ -36,11 +36,12 @@ being passed to the template is:
Stale bool // would 'go install' do anything for this package? Stale bool // would 'go install' do anything for this package?
// Source files // Source files
GoFiles []string // .go source files (excluding CgoFiles) GoFiles []string // .go source files (excluding CgoFiles and TestGoFiles)
CFiles []string // .c source files TestGoFiles []string // _test.go source files
HFiles []string // .h source files CFiles []string // .c source files
SFiles []string // .s source files HFiles []string // .h source files
CgoFiles []string // .go sources files that import "C" SFiles []string // .s source files
CgoFiles []string // .go sources files that import "C"
// Dependency information // Dependency information
Imports []string // import paths used by this package Imports []string // import paths used by this package
......
...@@ -29,13 +29,14 @@ type Package struct { ...@@ -29,13 +29,14 @@ type Package struct {
Stale bool `json:",omitempty"` // would 'go install' do anything for this package? Stale bool `json:",omitempty"` // would 'go install' do anything for this package?
// Source files // Source files
GoFiles []string // .go source files (excluding CgoFiles) GoFiles []string // .go source files (excluding CgoFiles and TestGoFiles)
CFiles []string `json:",omitempty"` // .c source files TestGoFiles []string `json:",omitempty"` // _test.go source files
HFiles []string `json:",omitempty"` // .h source files CFiles []string `json:",omitempty"` // .c source files
SFiles []string `json:",omitempty"` // .s source files HFiles []string `json:",omitempty"` // .h source files
CgoFiles []string `json:",omitempty"` // .go sources files that import "C" SFiles []string `json:",omitempty"` // .s source files
CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler CgoFiles []string `json:",omitempty"` // .go sources files that import "C"
CgoLDFLAGS []string `json:",omitempty"` // cgo: flags for linker CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler
CgoLDFLAGS []string `json:",omitempty"` // cgo: flags for linker
// Dependency information // Dependency information
Imports []string `json:",omitempty"` // import paths used by this package Imports []string `json:",omitempty"` // import paths used by this package
...@@ -46,7 +47,7 @@ type Package struct { ...@@ -46,7 +47,7 @@ type Package struct {
pkgdir string pkgdir string
info *build.DirInfo info *build.DirInfo
imports []*Package imports []*Package
gofiles []string // GoFiles+CgoFiles, absolute paths gofiles []string // GoFiles+CgoFiles+TestGoFiles files, absolute paths
target string // installed file for this package (may be executable) target string // installed file for this package (may be executable)
fake bool // synthesized package fake bool // synthesized package
} }
...@@ -126,22 +127,23 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string ...@@ -126,22 +127,23 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string
} }
p := &Package{ p := &Package{
Name: info.Package, Name: info.Package,
Doc: doc.CommentText(info.PackageComment), Doc: doc.CommentText(info.PackageComment),
ImportPath: importPath, ImportPath: importPath,
Dir: dir, Dir: dir,
Imports: info.Imports, Imports: info.Imports,
GoFiles: info.GoFiles, GoFiles: info.GoFiles,
CFiles: info.CFiles, TestGoFiles: info.TestGoFiles,
HFiles: info.HFiles, CFiles: info.CFiles,
SFiles: info.SFiles, HFiles: info.HFiles,
CgoFiles: info.CgoFiles, SFiles: info.SFiles,
CgoCFLAGS: info.CgoCFLAGS, CgoFiles: info.CgoFiles,
CgoLDFLAGS: info.CgoLDFLAGS, CgoCFLAGS: info.CgoCFLAGS,
Standard: t.Goroot && !strings.Contains(importPath, "."), CgoLDFLAGS: info.CgoLDFLAGS,
target: target, Standard: t.Goroot && !strings.Contains(importPath, "."),
t: t, target: target,
info: info, t: t,
info: info,
} }
var built time.Time var built time.Time
...@@ -157,7 +159,12 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string ...@@ -157,7 +159,12 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string
for _, f := range info.CgoFiles { for _, f := range info.CgoFiles {
p.gofiles = append(p.gofiles, filepath.Join(dir, f)) p.gofiles = append(p.gofiles, filepath.Join(dir, f))
} }
for _, f := range info.TestGoFiles {
p.gofiles = append(p.gofiles, filepath.Join(dir, f))
}
sort.Strings(p.gofiles) sort.Strings(p.gofiles)
srcss := [][]string{ srcss := [][]string{
p.GoFiles, p.GoFiles,
p.CFiles, p.CFiles,
......
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