aboutsummaryrefslogtreecommitdiff
path: root/go/packages/gopackages
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2018-07-13 12:09:24 -0400
committerAlan Donovan <adonovan@google.com>2018-07-13 17:38:36 +0000
commit18e9dfbf20567d5156dd6f1dd987092c021f7fa6 (patch)
treee6a55b5c5abbd3f94e58cc35fb7b6a46de8ab464 /go/packages/gopackages
parent9d3ae49c73ce10a6e25424c99b6cf42439ebbd88 (diff)
downloadgolang-x-tools-18e9dfbf20567d5156dd6f1dd987092c021f7fa6.tar.gz
go/packages: add Option.Tests bool, which affects pattern expansion
In the go build system, test packages and executables do not have a name distinct from the package under test; they are implied, so "go test fmt" means build those packages but "go build fmt" does not. This change adds a Tests boolean option to indicate that implied tests are desired during pattern expansion. It has no effect on build systems that have explicit names for tests, such as Blaze/Bazel. The gopackages diagnostic tool now has a -test flag. Change-Id: I424f343958c4286539e518d5f30067da19a57f3b Reviewed-on: https://go-review.googlesource.com/123775 Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'go/packages/gopackages')
-rw-r--r--go/packages/gopackages/main.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/go/packages/gopackages/main.go b/go/packages/gopackages/main.go
index b864e821c..6be503df2 100644
--- a/go/packages/gopackages/main.go
+++ b/go/packages/gopackages/main.go
@@ -27,6 +27,7 @@ import (
// flags
var (
depsFlag = flag.Bool("deps", false, "show dependencies too")
+ testFlag = flag.Bool("test", false, "include any tests implied by the patterns")
cgoFlag = flag.Bool("cgo", true, "process cgo files")
mode = flag.String("mode", "metadata", "mode (one of metadata, typecheck, wholeprogram)")
private = flag.Bool("private", false, "show non-exported declarations too")
@@ -119,6 +120,7 @@ func main() {
opts := &packages.Options{
Error: func(error) {}, // we'll take responsibility for printing errors
DisableCgo: !*cgoFlag,
+ Tests: *testFlag,
}
lpkgs, err := load(opts, flag.Args()...)
if err != nil {