Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201105173854-bc9fc8d8c4bc / go / analysis / passes / buildtag / buildtag_test.go
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.
4
5 package buildtag_test
6
7 import (
8         "testing"
9
10         "golang.org/x/tools/go/analysis"
11         "golang.org/x/tools/go/analysis/analysistest"
12         "golang.org/x/tools/go/analysis/passes/buildtag"
13 )
14
15 func Test(t *testing.T) {
16         analyzer := *buildtag.Analyzer
17         analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
18                 defer func() {
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.)
25                         var files []string
26                         files = append(files, pass.OtherFiles...)
27                         files = append(files, pass.IgnoredFiles...)
28                         pass.OtherFiles = files
29                 }()
30
31                 return buildtag.Analyzer.Run(pass)
32         }
33         analysistest.Run(t, analysistest.TestData(), &analyzer, "a")
34 }