1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 "golang.org/x/tools/go/analysis"
11 "golang.org/x/tools/go/analysis/analysistest"
12 "golang.org/x/tools/go/analysis/passes/buildtag"
15 func Test(t *testing.T) {
16 analyzer := *buildtag.Analyzer
17 analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
19 // The buildtag pass is unusual in that it checks the IgnoredFiles.
20 // After analysis, add IgnoredFiles to OtherFiles so that
21 // the test harness checks for expected diagnostics in those.
22 // (The test harness shouldn't do this by default because most
23 // passes can't do anything with the IgnoredFiles without type
24 // information, which is unavailable because they are ignored.)
26 files = append(files, pass.OtherFiles...)
27 files = append(files, pass.IgnoredFiles...)
28 pass.OtherFiles = files
31 return buildtag.Analyzer.Run(pass)
33 analysistest.Run(t, analysistest.TestData(), &analyzer, "a")