Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / lint / testutil / util.go
1 package testutil
2
3 import (
4         "testing"
5
6         "golang.org/x/tools/go/analysis"
7         "golang.org/x/tools/go/analysis/analysistest"
8 )
9
10 type Test struct {
11         Dir     string
12         Version string
13 }
14
15 func Run(t *testing.T, analyzers map[string]*analysis.Analyzer, tests map[string][]Test) {
16         for _, a := range analyzers {
17                 a := a
18                 t.Run(a.Name, func(t *testing.T) {
19                         t.Parallel()
20                         tt, ok := tests[a.Name]
21                         if !ok {
22                                 t.Fatalf("no tests for analyzer %s", a.Name)
23                         }
24                         for _, test := range tt {
25                                 if test.Version != "" {
26                                         if err := a.Flags.Lookup("go").Value.Set(test.Version); err != nil {
27                                                 t.Fatal(err)
28                                         }
29                                 }
30                                 analysistest.Run(t, analysistest.TestData(), a, test.Dir)
31                         }
32                 })
33         }
34 }