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
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/lint/testutil/util.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/lint/testutil/util.go
new file mode 100644 (file)
index 0000000..c93210a
--- /dev/null
@@ -0,0 +1,34 @@
+package testutil
+
+import (
+       "testing"
+
+       "golang.org/x/tools/go/analysis"
+       "golang.org/x/tools/go/analysis/analysistest"
+)
+
+type Test struct {
+       Dir     string
+       Version string
+}
+
+func Run(t *testing.T, analyzers map[string]*analysis.Analyzer, tests map[string][]Test) {
+       for _, a := range analyzers {
+               a := a
+               t.Run(a.Name, func(t *testing.T) {
+                       t.Parallel()
+                       tt, ok := tests[a.Name]
+                       if !ok {
+                               t.Fatalf("no tests for analyzer %s", a.Name)
+                       }
+                       for _, test := range tt {
+                               if test.Version != "" {
+                                       if err := a.Flags.Lookup("go").Value.Set(test.Version); err != nil {
+                                               t.Fatal(err)
+                                       }
+                               }
+                               analysistest.Run(t, analysistest.TestData(), a, test.Dir)
+                       }
+               })
+       }
+}