2018-02-15 11:23:36 +00:00
|
|
|
Before:
|
2019-08-02 08:09:10 +00:00
|
|
|
Save g:ale_go_go111module
|
2021-05-27 21:03:39 +00:00
|
|
|
Save $GOPATH
|
|
|
|
|
|
|
|
let $GOPATH = '/non/existent/directory'
|
2019-08-02 08:09:10 +00:00
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
call ale#assert#SetUpLinterTest('go', 'staticcheck')
|
2018-02-15 11:23:36 +00:00
|
|
|
call ale#test#SetFilename('test.go')
|
|
|
|
|
|
|
|
After:
|
2019-08-02 08:09:10 +00:00
|
|
|
unlet! b:ale_go_go111module
|
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
call ale#assert#TearDownLinterTest()
|
2018-02-15 11:23:36 +00:00
|
|
|
|
|
|
|
Execute(The staticcheck callback should return the right defaults):
|
2021-03-01 20:11:10 +00:00
|
|
|
AssertLinterCwd '%s:h'
|
2021-07-03 09:40:01 +00:00
|
|
|
AssertLinter 'staticcheck', ale#Escape('staticcheck') . ' .'
|
2021-05-27 21:03:39 +00:00
|
|
|
|
|
|
|
Execute(staticcheck 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/staticcheck'),
|
|
|
|
\ ale#Escape(ale#test#GetFilename('../test-files/go/gopath/bin/staticcheck'))
|
2021-07-03 09:40:01 +00:00
|
|
|
\ . ' .'
|
2018-02-15 11:23:36 +00:00
|
|
|
|
|
|
|
Execute(The staticcheck callback should use configured options):
|
|
|
|
let b:ale_go_staticcheck_options = '-test'
|
|
|
|
|
2021-07-03 09:40:01 +00:00
|
|
|
AssertLinter 'staticcheck', ale#Escape('staticcheck') . ' -test .'
|
2018-02-15 11:23:36 +00:00
|
|
|
|
2021-07-03 09:40:01 +00:00
|
|
|
Execute(Unset the staticcheck `lint_package` option should use the correct command):
|
|
|
|
let b:ale_go_staticcheck_lint_package = 0
|
2018-02-15 11:23:36 +00:00
|
|
|
|
2021-03-01 20:11:10 +00:00
|
|
|
AssertLinterCwd '%s:h'
|
2021-07-03 09:40:01 +00:00
|
|
|
AssertLinter 'staticcheck', ale#Escape('staticcheck') . ' %s:t'
|
2019-04-11 02:25:06 +00:00
|
|
|
|
|
|
|
Execute(The staticcheck callback should use the `GO111MODULE` option if set):
|
|
|
|
let b:ale_go_go111module = 'off'
|
|
|
|
|
2021-05-27 21:03:39 +00:00
|
|
|
AssertLinter 'staticcheck',
|
2021-07-03 09:40:01 +00:00
|
|
|
\ ale#Env('GO111MODULE', 'off') . ale#Escape('staticcheck') . ' .'
|
2019-04-11 02:25:06 +00:00
|
|
|
|
|
|
|
" Test with lint_package option set
|
2021-07-03 09:40:01 +00:00
|
|
|
let b:ale_go_staticcheck_lint_package = 0
|
2019-08-02 08:09:10 +00:00
|
|
|
|
2021-05-27 21:03:39 +00:00
|
|
|
AssertLinter 'staticcheck',
|
2021-07-03 09:40:01 +00:00
|
|
|
\ ale#Env('GO111MODULE', 'off') . ale#Escape('staticcheck') . ' %s:t'
|