Massively reduce the amount of code needed for linter tests

This commit is contained in:
w0rp
2018-07-15 18:24:53 +01:00
parent 5155a35a80
commit a42999a639
138 changed files with 1447 additions and 3017 deletions

View File

@@ -1,63 +1,35 @@
Before:
Save g:ale_cpp_clangcheck_executable
Save g:ale_cpp_clangcheck_options
unlet! g:ale_cpp_clangcheck_executable
unlet! b:ale_cpp_clangcheck_executable
unlet! g:ale_cpp_clangcheck_options
unlet! b:ale_cpp_clangcheck_options
runtime ale_linters/cpp/clangcheck.vim
call ale#assert#SetUpLinterTest('cpp', 'clangcheck')
After:
Restore
unlet! b:command_tail
unlet! b:ale_cpp_clangcheck_executable
unlet! b:ale_cpp_clangcheck_options
unlet! b:ale_c_build_dir
call ale#linter#Reset()
call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
AssertEqual 'clang-check', ale_linters#cpp#clangcheck#GetExecutable(bufnr(''))
let b:ale_cpp_clangcheck_executable = 'foobar'
AssertEqual 'foobar', ale_linters#cpp#clangcheck#GetExecutable(bufnr(''))
Execute(The executable should be used in the command):
AssertEqual
AssertLinter 'clang-check',
\ ale#Escape('clang-check')
\ . ' -analyze %s'
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
\ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
\ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text'
let b:ale_cpp_clangcheck_executable = 'foobar'
" The extra arguments in the command are used to prevent .plist files from
" being generated.
AssertEqual
AssertLinter 'foobar',
\ ale#Escape('foobar')
\ . ' -analyze %s'
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
\ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
\ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text'
Execute(The options should be configurable):
let b:ale_cpp_clangcheck_options = '--something'
AssertEqual
AssertLinter 'clang-check',
\ ale#Escape('clang-check')
\ . ' -analyze %s'
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text'
\ . ' --something',
\ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
\ . ' --something'
Execute(The build directory should be used when set):
let b:ale_cpp_clangcheck_options = '--something'
let b:ale_c_build_dir = '/foo/bar'
AssertEqual
AssertLinter 'clang-check',
\ ale#Escape('clang-check')
\ . ' -analyze %s '
\ . '--something -p '
\ . ale#Escape('/foo/bar'),
\ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
\ . ' -analyze %s --something -p ' . ale#Escape('/foo/bar')