1
0
mirror of https://github.com/golang/go synced 2024-11-25 07:07:57 -07:00

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

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

Fixes #2649.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5502102
This commit is contained in:
Sanjay Menakuru 2012-01-05 10:37:15 +11:00 committed by Andrew Gerrand
parent 3f1eb94ef2
commit 2693232f16
2 changed files with 38 additions and 32 deletions

View File

@ -36,8 +36,9 @@ being passed to the template is:
Stale bool // would 'go install' do anything for this package?
// Source files
GoFiles []string // .go source files (excluding CgoFiles and TestGoFiles)
TestGoFiles []string // _test.go source files
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, and XTestGoFiles)
TestGoFiles []string // _test.go source files internal to the package they are testing
XTestGoFiles []string // _test.go source files external to the package they are testing
CFiles []string // .c source files
HFiles []string // .h source files
SFiles []string // .s source files

View File

@ -29,8 +29,9 @@ type Package struct {
Stale bool `json:",omitempty"` // would 'go install' do anything for this package?
// Source files
GoFiles []string // .go source files (excluding CgoFiles and TestGoFiles)
TestGoFiles []string `json:",omitempty"` // _test.go source files
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles and XTestGoFiles)
TestGoFiles []string `json:",omitempty"` // _test.go source files internal to the package they are testing
XTestGoFiles []string `json:",omitempty"` //_test.go source files external to the package they are testing
CFiles []string `json:",omitempty"` // .c source files
HFiles []string `json:",omitempty"` // .h source files
SFiles []string `json:",omitempty"` // .s source files
@ -47,7 +48,7 @@ type Package struct {
pkgdir string
info *build.DirInfo
imports []*Package
gofiles []string // GoFiles+CgoFiles+TestGoFiles files, absolute paths
gofiles []string // GoFiles+CgoFiles+TestGoFiles+XTestGoFiles files, absolute paths
target string // installed file for this package (may be executable)
fake bool // synthesized package
}
@ -134,6 +135,7 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string
Imports: info.Imports,
GoFiles: info.GoFiles,
TestGoFiles: info.TestGoFiles,
XTestGoFiles: info.XTestGoFiles,
CFiles: info.CFiles,
HFiles: info.HFiles,
SFiles: info.SFiles,
@ -162,6 +164,9 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string
for _, f := range info.TestGoFiles {
p.gofiles = append(p.gofiles, filepath.Join(dir, f))
}
for _, f := range info.XTestGoFiles {
p.gofiles = append(p.gofiles, filepath.Join(dir, f))
}
sort.Strings(p.gofiles)