diff options
author | w0rp <devw0rp@gmail.com> | 2021-05-26 22:43:30 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2021-05-26 22:43:33 +0100 |
commit | f53431331e2e2030a84de081baec93aad1e62363 (patch) | |
tree | c44ff92c5e4aaf6b39100e9ee40484a49ae39f78 /test | |
parent | 3f386ae5e988d6e1b39332a760f9e990d2df7f31 (diff) | |
download | ale-f53431331e2e2030a84de081baec93aad1e62363.zip |
Enable gopls by default with GOPATH detection
Diffstat (limited to 'test')
-rw-r--r-- | test/linter/test_gopls.vader | 37 | ||||
-rw-r--r-- | test/test-files/go/gopath/bin/gopls | 0 | ||||
-rw-r--r-- | test/test_filetype_linter_defaults.vader | 2 |
3 files changed, 29 insertions, 10 deletions
diff --git a/test/linter/test_gopls.vader b/test/linter/test_gopls.vader index 0f1558e9..1c91fa10 100644 --- a/test/linter/test_gopls.vader +++ b/test/linter/test_gopls.vader @@ -1,5 +1,8 @@ Before: Save g:ale_go_go111module + Save $GOPATH + + let $GOPATH = '/non/existent/directory' call ale#assert#SetUpLinterTest('go', 'gopls') @@ -14,16 +17,32 @@ After: call ale#assert#TearDownLinterTest() -Execute(should set correct defaults): +Execute(The default command should be correct): AssertLinter 'gopls', ale#Escape('gopls') . ' --mode stdio' -Execute(should configure gopls callback executable): +Execute(The executable should be configurable): let b:ale_go_gopls_executable = 'boo' - let b:ale_go_gopls_options = '' - AssertLinter 'boo', ale#Escape('boo') + AssertLinter 'boo', ale#Escape('boo') . ' --mode stdio' + +Execute(gopls should be found in GOPATH): + " This is a directory with a fake executable + let $GOPATH = ale#test#GetFilename('../test-files/go/gopath') + + AssertLinter + \ ale#test#GetFilename('../test-files/go/gopath/bin/gopls'), + \ ale#Escape(ale#test#GetFilename('../test-files/go/gopath/bin/gopls')) + \ . ' --mode stdio' + +Execute(Global settings should be preferre for gopls if use_global = 1): + " This is a directory with a fake executable + let $GOPATH = ale#test#GetFilename('../test-files/go/gopath') + let b:ale_go_gopls_executable = 'boo' + let b:ale_go_gopls_use_global = 1 + + AssertLinter 'boo', ale#Escape('boo') . ' --mode stdio' -Execute(should set gopls options): +Execute(Settings options should work): call ale#test#SetFilename('../test-files/go/go1/prj1/file.go') " let b:ale_completion_enabled = 1 let b:ale_go_gopls_options = '' @@ -39,18 +58,18 @@ Execute(should set gopls options): let b:ale_go_gopls_init_options = {'ui.diagnostic.analyses': {'composites': v:false}} AssertLSPOptions {'ui.diagnostic.analyses': {'composites': v:false}} -Execute(should support go environment variables): +Execute(Go environment variables should be passed on): let b:ale_go_go111module = 'off' AssertLinter 'gopls', \ ale#Env('GO111MODULE', 'off') . ale#Escape('gopls') . ' --mode stdio' -Execute(Should return directory for 'go.mod' if found in parent directory): +Execute(Project directories should be detected based on 'go.mod' being present): call ale#test#SetFilename('../test-files/go/test.go') AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/go') -Execute(Should return nearest directory with '.git' if found in parent directory): +Execute(Project directories with .git should be detected): call ale#test#SetFilename('test.go') if !isdirectory(g:dir . '/.git') @@ -59,7 +78,7 @@ Execute(Should return nearest directory with '.git' if found in parent directory AssertLSPProject g:dir -Execute(Should ignore 'go.mod' and return '.git' dir if modules off): +Execute('go.mod' should be ignored if modules are off): call ale#test#SetFilename('../test-files/go/test.go') let b:ale_go_go111module = 'off' diff --git a/test/test-files/go/gopath/bin/gopls b/test/test-files/go/gopath/bin/gopls new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/go/gopath/bin/gopls diff --git a/test/test_filetype_linter_defaults.vader b/test/test_filetype_linter_defaults.vader index d4e708ec..419800de 100644 --- a/test/test_filetype_linter_defaults.vader +++ b/test/test_filetype_linter_defaults.vader @@ -22,7 +22,7 @@ Execute(The defaults for the csh filetype should be correct): AssertEqual [], GetLinterNames('csh') Execute(The defaults for the go filetype should be correct): - AssertEqual ['gofmt', 'golint', 'govet'], GetLinterNames('go') + AssertEqual ['gofmt', 'golint', 'gopls', 'govet'], GetLinterNames('go') let g:ale_linters_explicit = 1 |