Merge pull request #2287 from kevinoid/vulture-options

Document and test ale_python_vulture_options
This commit is contained in:
w0rp 2019-02-10 23:24:31 +00:00 committed by GitHub
commit 5dbac4ab9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 77 additions and 0 deletions

View File

@ -671,6 +671,15 @@ g:ale_python_vulture_executable *g:ale_python_vulture_executable*
See |ale-integrations-local-executables|
g:ale_python_vulture_options *g:ale_python_vulture_options*
*b:ale_python_vulture_options*
Type: |String|
Default: `''`
This variable can be changed to add command-line arguments to the vulture
invocation.
g:ale_python_vulture_use_global *g:ale_python_vulture_use_global*
*b:ale_python_vulture_use_global*
Type: |Number|

View File

@ -0,0 +1,68 @@
Before:
call ale#assert#SetUpLinterTest('python', 'vulture')
call ale#test#SetFilename('test.py')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
unlet! b:bin_dir
unlet! b:executable
call ale#assert#TearDownLinterTest()
Execute(The vulture command callback should lint file directory by default):
AssertLinter 'vulture',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('vulture') . ' .'
Execute(The vulture command callback should lint project root, when present):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
AssertLinter 'vulture',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ale#Escape('vulture') . ' .'
Execute(The option for disabling change directory works and only lints file):
let g:ale_python_vulture_change_directory = 0
AssertLinter 'vulture', ale#Escape('vulture') . ' %s'
Execute(The vulture executable should be configurable, and escaped properly):
let g:ale_python_vulture_executable = 'executable with spaces'
AssertLinter 'executable with spaces',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('executable with spaces') . ' .'
Execute(The vulture command callback should let you set options):
let g:ale_python_vulture_options = '--some-option'
AssertLinter 'vulture',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('vulture') . ' --some-option .'
Execute(The vulture command callback should detect virtualenv directories and switch to the project root):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
let b:executable = ale#path#Simplify(
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/vulture'
\)
AssertLinter b:executable,
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape(b:executable) . ' .'
Execute(You should able able to use the global vulture instead):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_vulture_use_global = 1
AssertLinter 'vulture',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape('vulture') . ' .'
Execute(Setting executable to 'pipenv' appends 'run vulture'):
let g:ale_python_vulture_executable = 'path/to/pipenv'
AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run vulture' . ' .'