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
1 // Copyright 2019 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 cmd_test
6
7 import (
8         "fmt"
9         "os"
10         "path/filepath"
11         "regexp"
12         "runtime"
13         "testing"
14
15         "golang.org/x/tools/internal/lsp/cmd"
16         cmdtest "golang.org/x/tools/internal/lsp/cmd/test"
17         "golang.org/x/tools/internal/lsp/tests"
18         "golang.org/x/tools/internal/testenv"
19 )
20
21 func TestMain(m *testing.M) {
22         testenv.ExitIfSmallMachine()
23         os.Exit(m.Run())
24 }
25
26 func TestCommandLine(t *testing.T) {
27         cmdtest.TestCommandLine(t, "../testdata", tests.DefaultOptions)
28 }
29
30 func TestDefinitionHelpExample(t *testing.T) {
31         // TODO: https://golang.org/issue/32794.
32         t.Skip()
33         if runtime.GOOS == "android" {
34                 t.Skip("not all source files are available on android")
35         }
36         dir, err := os.Getwd()
37         if err != nil {
38                 t.Errorf("could not get wd: %v", err)
39                 return
40         }
41         ctx := tests.Context(t)
42         ts := cmdtest.NewTestServer(ctx, nil)
43         thisFile := filepath.Join(dir, "definition.go")
44         baseArgs := []string{"query", "definition"}
45         expect := regexp.MustCompile(`(?s)^[\w/\\:_-]+flag[/\\]flag.go:\d+:\d+-\d+: defined here as FlagSet struct {.*}$`)
46         for _, query := range []string{
47                 fmt.Sprintf("%v:%v:%v", thisFile, cmd.ExampleLine, cmd.ExampleColumn),
48                 fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} {
49                 args := append(baseArgs, query)
50                 r := cmdtest.NewRunner(nil, ctx, ts.Addr, nil)
51                 got, _ := r.NormalizeGoplsCmd(t, args...)
52                 if !expect.MatchString(got) {
53                         t.Errorf("test with %v\nexpected:\n%s\ngot:\n%s", args, expect, got)
54                 }
55         }
56 }