]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/linter/test_gopls.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / test / linter / test_gopls.vader
1 Before:
2   Save g:ale_go_go111module
3   Save $GOPATH
4
5   let $GOPATH = '/non/existent/directory'
6
7   call ale#assert#SetUpLinterTest('go', 'gopls')
8
9 After:
10   if isdirectory(g:dir . '/.git')
11     call delete(g:dir . '/.git', 'd')
12   endif
13
14   unlet! b:ale_go_go111module
15   unlet! b:ale_go_go111module
16   unlet! b:ale_completion_enabled
17
18   call ale#assert#TearDownLinterTest()
19
20 Execute(The default command should be correct):
21   AssertLinter 'gopls', ale#Escape('gopls') . ' --mode stdio'
22
23 Execute(The executable should be configurable):
24   let b:ale_go_gopls_executable = 'boo'
25
26   AssertLinter 'boo', ale#Escape('boo') . ' --mode stdio'
27
28 Execute(gopls should be found in GOPATH):
29   " This is a directory with a fake executable
30   let $GOPATH = ale#test#GetFilename('../test-files/go/gopath')
31
32   AssertLinter
33   \ ale#test#GetFilename('../test-files/go/gopath/bin/gopls'),
34   \ ale#Escape(ale#test#GetFilename('../test-files/go/gopath/bin/gopls'))
35   \   . ' --mode stdio'
36
37 Execute(Global settings should be preferre for gopls if use_global = 1):
38   " This is a directory with a fake executable
39   let $GOPATH = ale#test#GetFilename('../test-files/go/gopath')
40   let b:ale_go_gopls_executable = 'boo'
41   let b:ale_go_gopls_use_global = 1
42
43   AssertLinter 'boo', ale#Escape('boo') . ' --mode stdio'
44
45 Execute(Settings options should work):
46   call ale#test#SetFilename('../test-files/go/go1/prj1/file.go')
47   " let b:ale_completion_enabled = 1
48   let b:ale_go_gopls_options = ''
49
50   AssertLinter 'gopls',
51   \ ale#Escape('gopls') . ''
52
53   let b:ale_go_gopls_options = '--mode stdio --trace'
54
55   AssertLinter 'gopls',
56   \ ale#Escape('gopls') . ' --mode stdio --trace'
57
58   let b:ale_go_gopls_init_options = {'ui.diagnostic.analyses': {'composites': v:false}}
59   AssertLSPOptions {'ui.diagnostic.analyses': {'composites': v:false}}
60
61 Execute(Go environment variables should be passed on):
62   let b:ale_go_go111module = 'off'
63
64   AssertLinter 'gopls',
65   \ ale#Env('GO111MODULE', 'off') . ale#Escape('gopls') . ' --mode stdio'
66
67 Execute(Project directories should be detected based on 'go.mod' being present):
68   call ale#test#SetFilename('../test-files/go/test.go')
69
70   AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/go')
71
72 Execute(Project directories with .git should be detected):
73   call ale#test#SetFilename('test.go')
74
75   if !isdirectory(g:dir . '/.git')
76     call mkdir(g:dir . '/.git')
77   endif
78
79   AssertLSPProject g:dir
80
81 Execute('go.mod' should be ignored if modules are off):
82   call ale#test#SetFilename('../test-files/go/test.go')
83
84   let b:ale_go_go111module = 'off'
85   let b:parent_dir = ale#path#Simplify(g:dir . '/..')
86   let b:git_dir = b:parent_dir . '/.git'
87
88   if !isdirectory(b:git_dir)
89     call mkdir(b:git_dir)
90   endif
91
92   AssertLSPProject b:parent_dir
93
94   call delete(b:git_dir, 'd')
95   unlet! b:parent_dir
96   unlet! b:git_dir