]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: include external test files in the files sent to gofmt, govet, and gofix
authorSanjay Menakuru <balasanjay@gmail.com>
Wed, 4 Jan 2012 23:37:15 +0000 (10:37 +1100)
committerAndrew Gerrand <adg@golang.org>
Wed, 4 Jan 2012 23:37:15 +0000 (10:37 +1100)
Also, add XTestGoFiles to the go command's public api.

Fixes #2649.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5502102

src/cmd/go/list.go
src/cmd/go/pkg.go

index 9a1a4ecb14cc3b12e29293acf4c82d439172852b..2ffaa2f13fbab6019b4398edb2b1581124317dab 100644 (file)
@@ -36,12 +36,13 @@ 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
-        CFiles      []string // .c source files
-        HFiles      []string // .h source files
-        SFiles      []string // .s source files
-        CgoFiles    []string // .go sources files that import "C"
+        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
+        CgoFiles     []string // .go sources files that import "C"
 
         // Dependency information
         Imports []string // import paths used by this package
index d66f5242693f0f2232e99930d270021b4c2584c9..02a7d5b216856b3d500ca470574a177eba7f725e 100644 (file)
@@ -29,14 +29,15 @@ 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
-       CFiles      []string `json:",omitempty"` // .c source files
-       HFiles      []string `json:",omitempty"` // .h source files
-       SFiles      []string `json:",omitempty"` // .s source files
-       CgoFiles    []string `json:",omitempty"` // .go sources files that import "C"
-       CgoCFLAGS   []string `json:",omitempty"` // cgo: flags for C compiler
-       CgoLDFLAGS  []string `json:",omitempty"` // cgo: flags for linker
+       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
+       CgoFiles     []string `json:",omitempty"` // .go sources files that import "C"
+       CgoCFLAGS    []string `json:",omitempty"` // cgo: flags for C compiler
+       CgoLDFLAGS   []string `json:",omitempty"` // cgo: flags for linker
 
        // Dependency information
        Imports []string `json:",omitempty"` // import paths used by this package
@@ -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
 }
@@ -127,23 +128,24 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string
        }
 
        p := &Package{
-               Name:        info.Package,
-               Doc:         doc.CommentText(info.PackageComment),
-               ImportPath:  importPath,
-               Dir:         dir,
-               Imports:     info.Imports,
-               GoFiles:     info.GoFiles,
-               TestGoFiles: info.TestGoFiles,
-               CFiles:      info.CFiles,
-               HFiles:      info.HFiles,
-               SFiles:      info.SFiles,
-               CgoFiles:    info.CgoFiles,
-               CgoCFLAGS:   info.CgoCFLAGS,
-               CgoLDFLAGS:  info.CgoLDFLAGS,
-               Standard:    t.Goroot && !strings.Contains(importPath, "."),
-               target:      target,
-               t:           t,
-               info:        info,
+               Name:         info.Package,
+               Doc:          doc.CommentText(info.PackageComment),
+               ImportPath:   importPath,
+               Dir:          dir,
+               Imports:      info.Imports,
+               GoFiles:      info.GoFiles,
+               TestGoFiles:  info.TestGoFiles,
+               XTestGoFiles: info.XTestGoFiles,
+               CFiles:       info.CFiles,
+               HFiles:       info.HFiles,
+               SFiles:       info.SFiles,
+               CgoFiles:     info.CgoFiles,
+               CgoCFLAGS:    info.CgoCFLAGS,
+               CgoLDFLAGS:   info.CgoLDFLAGS,
+               Standard:     t.Goroot && !strings.Contains(importPath, "."),
+               target:       target,
+               t:            t,
+               info:         info,
        }
 
        var built time.Time
@@ -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)