diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-08-23 22:33:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-23 22:33:01 +0100 |
commit | 774c02552fe15a3a0a70215928f15b3352e63d8e (patch) | |
tree | cc6832e9fd063d437d351d8ed7048d6957289144 | |
parent | a366d325a7c69fa20a3ab69ff8359bcd37d1487a (diff) | |
parent | 18ec66bd21bd2c0f61a422bfd5498866385b9e70 (diff) | |
download | ale-774c02552fe15a3a0a70215928f15b3352e63d8e.zip |
Merge pull request #1840 from Carpetsmoker/gopath
Remove "go env" from gobuild linter
-rw-r--r-- | ale_linters/go/gobuild.vim | 34 | ||||
-rw-r--r-- | test/command_callback/test_gobuild_command_callback.vader | 25 |
2 files changed, 8 insertions, 51 deletions
diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim index c4608071..2d6febdd 100644 --- a/ale_linters/go/gobuild.vim +++ b/ale_linters/go/gobuild.vim @@ -5,35 +5,11 @@ call ale#Set('go_gobuild_options', '') -function! ale_linters#go#gobuild#ResetEnv() abort - unlet! s:go_env -endfunction - -function! ale_linters#go#gobuild#GoEnv(buffer) abort - if exists('s:go_env') - return '' - endif - - return 'go env GOPATH GOROOT' -endfunction - -function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort +function! ale_linters#go#gobuild#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'go_gobuild_options') - if !exists('s:go_env') - let s:go_env = { - \ 'GOPATH': a:goenv_output[0], - \ 'GOROOT': a:goenv_output[1], - \} - endif - - let l:gopath_env_command = has('win32') - \ ? 'set GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' && ' - \ : 'GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' ' - " Run go test in local directory with relative path - return l:gopath_env_command - \ . ale#path#BufferCdString(a:buffer) + return ale#path#BufferCdString(a:buffer) \ . 'go test' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -c -o /dev/null ./' @@ -73,10 +49,8 @@ call ale#linter#Define('go', { \ 'name': 'gobuild', \ 'aliases': ['go build'], \ 'executable': 'go', -\ 'command_chain': [ -\ {'callback': 'ale_linters#go#gobuild#GoEnv', 'output_stream': 'stdout'}, -\ {'callback': 'ale_linters#go#gobuild#GetCommand', 'output_stream': 'stderr'}, -\ ], +\ 'command_callback': 'ale_linters#go#gobuild#GetCommand', +\ 'output_stream': 'stderr', \ 'callback': 'ale_linters#go#gobuild#Handler', \ 'lint_file': 1, \}) diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader index 86113728..f9673213 100644 --- a/test/command_callback/test_gobuild_command_callback.vader +++ b/test/command_callback/test_gobuild_command_callback.vader @@ -1,36 +1,19 @@ Before: call ale#assert#SetUpLinterTest('go', 'gobuild') - let g:env_prefix = has('win32') - \ ? 'set GOPATH=' . ale#Escape('/foo/bar') . ' && ' - \ : 'GOPATH=' . ale#Escape('/foo/bar') . ' ' - call ale_linters#go#gobuild#ResetEnv() - WithChainResults ['/foo/bar', '/foo/baz'] After: - unlet! g:env_prefix call ale#assert#TearDownLinterTest() Execute(The default commands should be correct): - AssertLinter 'go', [ - \ 'go env GOPATH GOROOT', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' - \ . 'go test -c -o /dev/null ./' - \] - - " We shouldn't run `go env` many times after we've got it. - AssertLinter 'go', [ - \ '', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + AssertLinter 'go', + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ . 'go test -c -o /dev/null ./' - \] Execute(Extra options should be supported): let g:ale_go_gobuild_options = '--foo-bar' - AssertLinter 'go', [ - \ 'go env GOPATH GOROOT', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + AssertLinter 'go', + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ . 'go test --foo-bar -c -o /dev/null ./' - \] |