mirror of https://github.com/golang/go.git
go/analysis/internal/checker: add -test flag for single/multi-checkers
Like `go list -test`, allow users to control inclusion/exclusion of test files. Default is to include test files. Change-Id: I1af3077f087089ad2201571b4a2f781d936d0102 Reviewed-on: https://go-review.googlesource.com/c/tools/+/410365 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
43cce678a1
commit
2417911076
|
|
@ -51,6 +51,9 @@ var (
|
|||
// Log files for optional performance tracing.
|
||||
CPUProfile, MemProfile, Trace string
|
||||
|
||||
// IncludeTests indicates whether test files should be analyzed too.
|
||||
IncludeTests = true
|
||||
|
||||
// Fix determines whether to apply all suggested fixes.
|
||||
Fix bool
|
||||
)
|
||||
|
|
@ -65,6 +68,7 @@ func RegisterFlags() {
|
|||
flag.StringVar(&CPUProfile, "cpuprofile", "", "write CPU profile to this file")
|
||||
flag.StringVar(&MemProfile, "memprofile", "", "write memory profile to this file")
|
||||
flag.StringVar(&Trace, "trace", "", "write trace log to this file")
|
||||
flag.BoolVar(&IncludeTests, "test", IncludeTests, "indicates whether test files should be analyzed, too")
|
||||
|
||||
flag.BoolVar(&Fix, "fix", false, "apply all suggested fixes")
|
||||
}
|
||||
|
|
@ -163,7 +167,7 @@ func load(patterns []string, allSyntax bool) ([]*packages.Package, error) {
|
|||
}
|
||||
conf := packages.Config{
|
||||
Mode: mode,
|
||||
Tests: true,
|
||||
Tests: IncludeTests,
|
||||
}
|
||||
initial, err := packages.Load(&conf, patterns...)
|
||||
if err == nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue