Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / internal / lsp / cmd / cmd_test.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201028153306-37f0764111ff/internal/lsp/cmd/cmd_test.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201028153306-37f0764111ff/internal/lsp/cmd/cmd_test.go
new file mode 100644 (file)
index 0000000..46a862a
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cmd_test
+
+import (
+       "fmt"
+       "os"
+       "path/filepath"
+       "regexp"
+       "runtime"
+       "testing"
+
+       "golang.org/x/tools/internal/lsp/cmd"
+       cmdtest "golang.org/x/tools/internal/lsp/cmd/test"
+       "golang.org/x/tools/internal/lsp/tests"
+       "golang.org/x/tools/internal/testenv"
+)
+
+func TestMain(m *testing.M) {
+       testenv.ExitIfSmallMachine()
+       os.Exit(m.Run())
+}
+
+func TestCommandLine(t *testing.T) {
+       cmdtest.TestCommandLine(t, "../testdata", tests.DefaultOptions)
+}
+
+func TestDefinitionHelpExample(t *testing.T) {
+       // TODO: https://golang.org/issue/32794.
+       t.Skip()
+       if runtime.GOOS == "android" {
+               t.Skip("not all source files are available on android")
+       }
+       dir, err := os.Getwd()
+       if err != nil {
+               t.Errorf("could not get wd: %v", err)
+               return
+       }
+       ctx := tests.Context(t)
+       ts := cmdtest.NewTestServer(ctx, nil)
+       thisFile := filepath.Join(dir, "definition.go")
+       baseArgs := []string{"query", "definition"}
+       expect := regexp.MustCompile(`(?s)^[\w/\\:_-]+flag[/\\]flag.go:\d+:\d+-\d+: defined here as FlagSet struct {.*}$`)
+       for _, query := range []string{
+               fmt.Sprintf("%v:%v:%v", thisFile, cmd.ExampleLine, cmd.ExampleColumn),
+               fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} {
+               args := append(baseArgs, query)
+               r := cmdtest.NewRunner(nil, ctx, ts.Addr, nil)
+               got, _ := r.NormalizeGoplsCmd(t, args...)
+               if !expect.MatchString(got) {
+                       t.Errorf("test with %v\nexpected:\n%s\ngot:\n%s", args, expect, got)
+               }
+       }
+}