Allow linting rust tests and examples with cargo
This commit is contained in:
parent
4ec661b305
commit
e272207114
@ -4,6 +4,8 @@
|
||||
|
||||
call ale#Set('rust_cargo_use_check', 1)
|
||||
call ale#Set('rust_cargo_check_all_targets', 0)
|
||||
call ale#Set('rust_cargo_check_examples', 0)
|
||||
call ale#Set('rust_cargo_check_tests', 0)
|
||||
call ale#Set('rust_cargo_default_feature_behavior', 'default')
|
||||
call ale#Set('rust_cargo_include_features', '')
|
||||
|
||||
@ -31,6 +33,12 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort
|
||||
let l:use_all_targets = l:use_check
|
||||
\ && ale#Var(a:buffer, 'rust_cargo_check_all_targets')
|
||||
\ && ale#semver#GTE(l:version, [0, 22, 0])
|
||||
let l:use_examples = l:use_check
|
||||
\ && ale#Var(a:buffer, 'rust_cargo_check_examples')
|
||||
\ && ale#semver#GTE(l:version, [0, 22, 0])
|
||||
let l:use_tests = l:use_check
|
||||
\ && ale#Var(a:buffer, 'rust_cargo_check_tests')
|
||||
\ && ale#semver#GTE(l:version, [0, 22, 0])
|
||||
|
||||
let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features')
|
||||
if !empty(l:include_features)
|
||||
@ -50,6 +58,8 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort
|
||||
return 'cargo '
|
||||
\ . (l:use_check ? 'check' : 'build')
|
||||
\ . (l:use_all_targets ? ' --all-targets' : '')
|
||||
\ . (l:use_examples ? ' --examples' : '')
|
||||
\ . (l:use_tests ? ' --tests' : '')
|
||||
\ . ' --frozen --message-format=json -q'
|
||||
\ . l:default_feature
|
||||
\ . l:include_features
|
||||
|
@ -59,6 +59,26 @@ g:ale_rust_cargo_check_all_targets *g:ale_rust_cargo_check_all_targets*
|
||||
is used. See |g:ale_rust_cargo_use_check|,
|
||||
|
||||
|
||||
g:ale_rust_cargo_check_tests *g:ale_rust_cargo_check_tests*
|
||||
*b:ale_rust_cargo_check_tests*
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
When set to `1`, ALE will set the `--tests` option when `cargo check`
|
||||
is used. This allows for linting of tests which are normally excluded.
|
||||
See |g:ale_rust_cargo_use_check|,
|
||||
|
||||
|
||||
g:ale_rust_cargo_check_examples *g:ale_rust_cargo_check_examples*
|
||||
*b:ale_rust_cargo_check_examples*
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
When set to `1`, ALE will set the `--examples` option when `cargo check`
|
||||
is used. This allows for linting of examples which are normally excluded.
|
||||
See |g:ale_rust_cargo_use_check|,
|
||||
|
||||
|
||||
g:ale_rust_cargo_default_feature_behavior
|
||||
*g:ale_rust_cargo_default_feature_behavior*
|
||||
*b:ale_rust_cargo_default_feature_behavior*
|
||||
|
@ -1,11 +1,15 @@
|
||||
Before:
|
||||
Save g:ale_rust_cargo_use_check
|
||||
Save g:ale_rust_cargo_check_all_targets
|
||||
Save g:ale_rust_cargo_check_tests
|
||||
Save g:ale_rust_cargo_check_examples
|
||||
Save g:ale_rust_cargo_default_feature_behavior
|
||||
Save g:ale_rust_cargo_include_features
|
||||
|
||||
unlet! g:ale_rust_cargo_use_check
|
||||
unlet! g:ale_cargo_check_all_targets
|
||||
unlet! g:ale_rust_cargo_check_all_targets
|
||||
unlet! g:ale_rust_cargo_check_tests
|
||||
unlet! g:ale_rust_cargo_check_examples
|
||||
unlet! g:ale_rust_cargo_default_feature_behavior
|
||||
unlet! g:ale_rust_cargo_include_features
|
||||
|
||||
@ -119,6 +123,38 @@ Execute(--all-targets should be used when g:ale_rust_cargo_check_all_targets is
|
||||
|
||||
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
|
||||
|
||||
Execute(--tests should be used when g:ale_rust_cargo_check_tests is set to 1):
|
||||
let g:ale_rust_cargo_check_tests = 1
|
||||
|
||||
AssertEqual
|
||||
\ 'cargo check --tests' . g:suffix,
|
||||
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
|
||||
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
|
||||
\ ])
|
||||
|
||||
" We should cache the version check
|
||||
AssertEqual
|
||||
\ 'cargo check --tests' . g:suffix,
|
||||
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
|
||||
|
||||
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
|
||||
|
||||
Execute(--examples should be used when g:ale_rust_cargo_check_examples is set to 1):
|
||||
let g:ale_rust_cargo_check_examples = 1
|
||||
|
||||
AssertEqual
|
||||
\ 'cargo check --examples' . g:suffix,
|
||||
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
|
||||
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
|
||||
\ ])
|
||||
|
||||
" We should cache the version check
|
||||
AssertEqual
|
||||
\ 'cargo check --examples' . g:suffix,
|
||||
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
|
||||
|
||||
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
|
||||
|
||||
Execute(--no-default-features should be used when g:ale_rust_cargo_default_feature_behavior is none):
|
||||
let g:ale_rust_cargo_default_feature_behavior = 'none'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user