.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / 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         "runtime"
9         "strings"
10         "testing"
11
12         "golang.org/x/tools/go/analysis"
13         "golang.org/x/tools/go/analysis/analysistest"
14         "golang.org/x/tools/go/analysis/passes/buildtag"
15 )
16
17 func Test(t *testing.T) {
18         if strings.HasPrefix(runtime.Version(), "go1.") && runtime.Version() < "go1.16" {
19                 t.Skipf("skipping on %v", runtime.Version())
20         }
21         analyzer := *buildtag.Analyzer
22         analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
23                 defer func() {
24                         // The buildtag pass is unusual in that it checks the IgnoredFiles.
25                         // After analysis, add IgnoredFiles to OtherFiles so that
26                         // the test harness checks for expected diagnostics in those.
27                         // (The test harness shouldn't do this by default because most
28                         // passes can't do anything with the IgnoredFiles without type
29                         // information, which is unavailable because they are ignored.)
30                         var files []string
31                         files = append(files, pass.OtherFiles...)
32                         files = append(files, pass.IgnoredFiles...)
33                         pass.OtherFiles = files
34                 }()
35
36                 return buildtag.Analyzer.Run(pass)
37         }
38         analysistest.Run(t, analysistest.TestData(), &analyzer, "a")
39 }