go/packages: remove Package.IsTest field
We have not yet settled on the meaning of Package.IsTest, and more deeply which packages are test and which are non test packages. This change will remove Package.IsTest in the meantime to avoid confusion. We may later add a boolean or some other way to distinguish test and non-test packages. Change-Id: If6b128f7914009fdd42b8bc3de3bff73c8f006cd Reviewed-on: https://go-review.googlesource.com/124388 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
32950ab3be
commit
54f9f5980a
|
@ -172,12 +172,9 @@ files were nearly always missing or stale. Now that 'go build' supports
|
|||
caching, all the underlying build systems can guarantee to produce
|
||||
export data in a reasonable (amortized) time.
|
||||
|
||||
Packages that are part of a test are marked IsTest=true.
|
||||
Such packages include in-package tests, external tests,
|
||||
and the test "main" packages synthesized by the build system.
|
||||
The latter packages are reported as first-class packages,
|
||||
avoiding the need for clients (such as go/ssa) to reinvent this
|
||||
generation logic.
|
||||
Test "main" packages synthesized by the build system are now reported as
|
||||
first-class packages, avoiding the need for clients (such as go/ssa) to
|
||||
reinvent this generation logic.
|
||||
|
||||
One way in which go/packages is simpler than the old loader is in its
|
||||
treatment of in-package tests. In-package tests are packages that
|
||||
|
@ -307,4 +304,7 @@ Questions & Tasks
|
|||
|
||||
- Bug: "gopackages fmt a.go" doesn't produce an error.
|
||||
|
||||
- If necessary, add back an IsTest boolean or expose ForTests on the Package struct.
|
||||
IsTest was removed because we couldn't agree on a useful definition.
|
||||
|
||||
*/
|
||||
|
|
|
@ -107,10 +107,6 @@ func golistPackages(ctx context.Context, dir string, env []string, cgo, export,
|
|||
pkgpath = id[:i]
|
||||
}
|
||||
|
||||
// Is this a test?
|
||||
// ("foo [foo.test]" package or "foo.test" command)
|
||||
isTest := p.ForTest != "" || strings.HasSuffix(pkgpath, ".test")
|
||||
|
||||
if pkgpath == "unsafe" {
|
||||
p.GoFiles = nil // ignore fake unsafe.go file
|
||||
}
|
||||
|
@ -156,7 +152,6 @@ func golistPackages(ctx context.Context, dir string, env []string, cgo, export,
|
|||
ID: id,
|
||||
Name: p.Name,
|
||||
PkgPath: pkgpath,
|
||||
IsTest: isTest,
|
||||
Srcs: absJoin(p.Dir, p.GoFiles, p.CgoFiles),
|
||||
OtherSrcs: absJoin(p.Dir, p.SFiles, p.CFiles),
|
||||
imports: imports,
|
||||
|
|
|
@ -165,9 +165,8 @@ func main() {
|
|||
func print(lpkg *packages.Package) {
|
||||
// title
|
||||
var kind string
|
||||
if lpkg.IsTest {
|
||||
kind = "test "
|
||||
}
|
||||
// TODO(matloob): If IsTest is added back print "test command" or
|
||||
// "test package" for packages with IsTest == true.
|
||||
if lpkg.Name == "main" {
|
||||
kind += "command"
|
||||
} else {
|
||||
|
|
|
@ -211,9 +211,6 @@ type Package struct {
|
|||
// The name of an executable is "main".
|
||||
Name string
|
||||
|
||||
// IsTest indicates whether this package is a test.
|
||||
IsTest bool
|
||||
|
||||
// Srcs is the list of names of this package's Go
|
||||
// source files as presented to the compiler.
|
||||
// Names are guaranteed to be absolute.
|
||||
|
|
|
@ -145,7 +145,7 @@ func TestMetadataImportGraph(t *testing.T) {
|
|||
{"e", "main", "command", "e.go e2.go"},
|
||||
{"errors", "errors", "package", "errors.go"},
|
||||
{"subdir/d", "d", "package", "d.go"},
|
||||
{"subdir/d.test", "main", "test command", "0.go"},
|
||||
{"subdir/d.test", "main", "command", "0.go"},
|
||||
{"unsafe", "unsafe", "package", ""},
|
||||
} {
|
||||
p, ok := all[test.id]
|
||||
|
@ -159,9 +159,6 @@ func TestMetadataImportGraph(t *testing.T) {
|
|||
|
||||
// kind
|
||||
var kind string
|
||||
if p.IsTest {
|
||||
kind = "test "
|
||||
}
|
||||
if p.Name == "main" {
|
||||
kind += "command"
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue