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
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
138 changed files with 1447 additions and 3017 deletions

View File

@ -15,9 +15,9 @@ function! ale_linters#awk#gawk#GetCommand(buffer) abort
" note the --source 'BEGIN ...' is to prevent " note the --source 'BEGIN ...' is to prevent
" gawk from attempting to execute the body of the script " gawk from attempting to execute the body of the script
" it is linting. " it is linting.
return ale_linters#awk#gawk#GetExecutable(a:buffer) return ale#Escape(ale_linters#awk#gawk#GetExecutable(a:buffer))
\ . " --source 'BEGIN { exit } END { exit 1 }'" \ . " --source 'BEGIN { exit } END { exit 1 }'"
\ . ' ' . ale#Var(a:buffer, 'awk_gawk_options') \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
\ . ' ' . '-f %t --lint /dev/null' \ . ' ' . '-f %t --lint /dev/null'
endfunction endfunction

View File

@ -1,7 +1,11 @@
let g:ale_cs_mcs_options = get(g:, 'ale_cs_mcs_options', '') let g:ale_cs_mcs_options = get(g:, 'ale_cs_mcs_options', '')
function! ale_linters#cs#mcs#GetCommand(buffer) abort function! ale_linters#cs#mcs#GetCommand(buffer) abort
return 'mcs -unsafe --parse ' . ale#Var(a:buffer, 'cs_mcs_options') . ' %t' let l:options = ale#Var(a:buffer, 'cs_mcs_options')
return 'mcs -unsafe --parse'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' %t'
endfunction endfunction
function! ale_linters#cs#mcs#Handle(buffer, lines) abort function! ale_linters#cs#mcs#Handle(buffer, lines) abort

View File

@ -29,16 +29,16 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort
\ : '' \ : ''
" register temporary module target file with ale " register temporary module target file with ale
let l:out = ale#util#Tempname() " register temporary module target file with ALE.
call ale#engine#ManageFile(a:buffer, l:out) let l:out = ale#engine#CreateFile(a:buffer)
" The code is compiled as a module and the output is redirected to a " The code is compiled as a module and the output is redirected to a
" temporary file. " temporary file.
return ale#path#CdString(s:GetWorkingDirectory(a:buffer)) return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
\ . 'mcs -unsafe' \ . 'mcs -unsafe'
\ . ' ' . ale#Var(a:buffer, 'cs_mcsc_options') \ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options'))
\ . ' ' . l:lib_option \ . ale#Pad(l:lib_option)
\ . ' ' . l:r_option \ . ale#Pad(l:r_option)
\ . ' -out:' . l:out \ . ' -out:' . l:out
\ . ' -t:module' \ . ' -t:module'
\ . ' -recurse:' . ale#Escape('*.cs') \ . ' -recurse:' . ale#Escape('*.cs')

View File

@ -1,11 +1,8 @@
" Author: RyanSquared <vandor2012@gmail.com> " Author: RyanSquared <vandor2012@gmail.com>
" Description: `fusion-lint` linter for FusionScript files " Description: `fusion-lint` linter for FusionScript files
let g:ale_fuse_fusionlint_executable = call ale#Set('fuse_fusionlint_executable', 'fusion-lint')
\ get(g:, 'ale_fuse_fusionlint_executable', 'fusion-lint') call ale#Set('fuse_fusionlint_options', '')
let g:ale_fuse_fusionlint_options =
\ get(g:, 'ale_fuse_fusionlint_options', '')
function! ale_linters#fuse#fusionlint#GetExecutable(buffer) abort function! ale_linters#fuse#fusionlint#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'fuse_fusionlint_executable') return ale#Var(a:buffer, 'fuse_fusionlint_executable')
@ -13,7 +10,7 @@ endfunction
function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort
return ale#Escape(ale_linters#fuse#fusionlint#GetExecutable(a:buffer)) return ale#Escape(ale_linters#fuse#fusionlint#GetExecutable(a:buffer))
\ . ' ' . ale#Var(a:buffer, 'fuse_fusionlint_options') \ . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options'))
\ . ' --filename %s -i' \ . ' --filename %s -i'
endfunction endfunction

View File

@ -14,9 +14,9 @@ function! ale_linters#glsl#glslang#GetExecutable(buffer) abort
endfunction endfunction
function! ale_linters#glsl#glslang#GetCommand(buffer) abort function! ale_linters#glsl#glslang#GetCommand(buffer) abort
return ale_linters#glsl#glslang#GetExecutable(a:buffer) return ale#Escape(ale_linters#glsl#glslang#GetExecutable(a:buffer))
\ . ' ' . ale#Var(a:buffer, 'glsl_glslang_options') \ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options'))
\ . ' ' . '-C %t' \ . ' -C %t'
endfunction endfunction
function! ale_linters#glsl#glslang#Handle(buffer, lines) abort function! ale_linters#glsl#glslang#Handle(buffer, lines) abort

View File

@ -3,10 +3,9 @@
function! ale_linters#go#gotype#GetCommand(buffer) abort function! ale_linters#go#gotype#GetCommand(buffer) abort
if expand('#' . a:buffer . ':p') =~# '_test\.go$' if expand('#' . a:buffer . ':p') =~# '_test\.go$'
return return ''
endif endif
return ale#path#BufferCdString(a:buffer) . ' gotype .' return ale#path#BufferCdString(a:buffer) . ' gotype .'
endfunction endfunction

View File

@ -84,10 +84,10 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
return ale#path#BufferCdString(a:buffer) return ale#path#BufferCdString(a:buffer)
\ . ale#Escape(l:executable) \ . ale#Escape(l:executable)
\ . ' -Xlint' \ . ' -Xlint'
\ . ' ' . l:cp_option \ . ale#Pad(l:cp_option)
\ . ' ' . l:sp_option \ . ale#Pad(l:sp_option)
\ . ' -d ' . ale#Escape(l:class_file_directory) \ . ' -d ' . ale#Escape(l:class_file_directory)
\ . ' ' . ale#Var(a:buffer, 'java_javac_options') \ . ale#Pad(ale#Var(a:buffer, 'java_javac_options'))
\ . ' %t' \ . ' %t'
endfunction endfunction

View File

@ -9,8 +9,7 @@ endfunction
function! ale_linters#llvm#llc#GetCommand(buffer) abort function! ale_linters#llvm#llc#GetCommand(buffer) abort
return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer)) return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer))
\ . ' -filetype=null -o=' \ . ' -filetype=null -o=' . g:ale#util#nul_file
\ . ale#Escape(g:ale#util#nul_file)
endfunction endfunction
function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort

View File

@ -42,9 +42,9 @@ endfunction
call ale#linter#Define('nasm', { call ale#linter#Define('nasm', {
\ 'name': 'nasm', \ 'name': 'nasm',
\ 'executable': 'nasm',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'lint_file': 1, \ 'lint_file': 1,
\ 'executable_callback': 'ale_linters#nasm#nasm#GetExecutable',
\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand', \ 'command_callback': 'ale_linters#nasm#nasm#GetCommand',
\ 'callback': 'ale_linters#nasm#nasm#Handle', \ 'callback': 'ale_linters#nasm#nasm#Handle',
\}) \})

View File

@ -1,8 +1,8 @@
" Author: Eddie Lebow https://github.com/elebow " Author: Eddie Lebow https://github.com/elebow
" Description: rails_best_practices, a code metric tool for rails projects " Description: rails_best_practices, a code metric tool for rails projects
let g:ale_ruby_rails_best_practices_options = call ale#Set('ruby_rails_best_practices_options', '')
\ get(g:, 'ale_ruby_rails_best_practices_options', '') call ale#Set('ruby_rails_best_practices_executable', 'rails_best_practices')
function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort
let l:output = [] let l:output = []
@ -22,8 +22,12 @@ function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort
return l:output return l:output
endfunction endfunction
function! ale_linters#ruby#rails_best_practices#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'ruby_rails_best_practices_executable')
endfunction
function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort
let l:executable = ale#handlers#rails_best_practices#GetExecutable(a:buffer) let l:executable = ale_linters#ruby#rails_best_practices#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'bundle$' let l:exec_args = l:executable =~? 'bundle$'
\ ? ' exec rails_best_practices' \ ? ' exec rails_best_practices'
\ : '' \ : ''
@ -46,7 +50,7 @@ endfunction
call ale#linter#Define('ruby', { call ale#linter#Define('ruby', {
\ 'name': 'rails_best_practices', \ 'name': 'rails_best_practices',
\ 'executable_callback': 'ale#handlers#rails_best_practices#GetExecutable', \ 'executable_callback': 'ale_linters#ruby#rails_best_practices#GetExecutable',
\ 'command_callback': 'ale_linters#ruby#rails_best_practices#GetCommand', \ 'command_callback': 'ale_linters#ruby#rails_best_practices#GetCommand',
\ 'callback': 'ale_linters#ruby#rails_best_practices#Handle', \ 'callback': 'ale_linters#ruby#rails_best_practices#Handle',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -1,11 +1,11 @@
" Author: Kevin Kays - https://github.com/okkays " Author: Kevin Kays - https://github.com/okkays
" Description: Support for the scalastyle checker. " Description: Support for the scalastyle checker.
let g:ale_scala_scalastyle_options = call ale#Set('scala_scalastyle_options', '')
\ get(g:, 'ale_scala_scalastyle_options', '') " TODO: Remove support for the old option name in ALE 3.0.
call ale#Set('scala_scalastyle_config',
let g:ale_scalastyle_config_loc =
\ get(g:, 'ale_scalastyle_config_loc', '') \ get(g:, 'ale_scalastyle_config_loc', '')
\)
function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort
" Look for help output from scalastyle first, which indicates that no " Look for help output from scalastyle first, which indicates that no
@ -66,23 +66,13 @@ function! ale_linters#scala#scalastyle#GetCommand(buffer) abort
" If all else fails, try the global config. " If all else fails, try the global config.
if empty(l:scalastyle_config) if empty(l:scalastyle_config)
let l:scalastyle_config = get(g:, 'ale_scalastyle_config_loc', '') let l:scalastyle_config = ale#Var(a:buffer, 'scala_scalastyle_config')
endif endif
" Build the command using the config file and additional options. return 'scalastyle'
let l:command = 'scalastyle' \ . (!empty(l:scalastyle_config) ? ' --config ' . ale#Escape(l:scalastyle_config) : '')
\ . ale#Pad(ale#Var(a:buffer, 'scala_scalastyle_options'))
if !empty(l:scalastyle_config) \ . ' %t'
let l:command .= ' --config ' . ale#Escape(l:scalastyle_config)
endif
if !empty(g:ale_scala_scalastyle_options)
let l:command .= ' ' . g:ale_scala_scalastyle_options
endif
let l:command .= ' %t'
return l:command
endfunction endfunction
call ale#linter#Define('scala', { call ale#linter#Define('scala', {

View File

@ -20,14 +20,12 @@ function! ale_linters#thrift#thrift#GetCommand(buffer) abort
let l:generators = ['cpp'] let l:generators = ['cpp']
endif endif
let l:output_dir = ale#util#Tempname() let l:output_dir = ale#engine#CreateDirectory(a:buffer)
call mkdir(l:output_dir)
call ale#engine#ManageDirectory(a:buffer, l:output_dir)
return ale#Escape(ale_linters#thrift#thrift#GetExecutable(a:buffer)) return ale#Escape(ale_linters#thrift#thrift#GetExecutable(a:buffer))
\ . ' ' . join(map(copy(l:generators), "'--gen ' . v:val")) \ . ale#Pad(join(map(copy(l:generators), "'--gen ' . v:val")))
\ . ' ' . join(map(copy(l:includes), "'-I ' . v:val")) \ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val")))
\ . ' ' . ale#Var(a:buffer, 'thrift_thrift_options') \ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options'))
\ . ' -out ' . ale#Escape(l:output_dir) \ . ' -out ' . ale#Escape(l:output_dir)
\ . ' %t' \ . ' %t'
endfunction endfunction

View File

@ -1,17 +1,7 @@
" Author: Prashanth Chandra <https://github.com/prashcr>, Jonathan Clem <https://jclem.net> " Author: Prashanth Chandra <https://github.com/prashcr>, Jonathan Clem <https://jclem.net>
" Description: tslint for TypeScript files " Description: tslint for TypeScript files
call ale#Set('typescript_tslint_executable', 'tslint') call ale#handlers#tslint#InitVariables()
call ale#Set('typescript_tslint_config_path', '')
call ale#Set('typescript_tslint_rules_dir', '')
call ale#Set('typescript_tslint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('typescript_tslint_ignore_empty_files', 0)
function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [
\ 'node_modules/.bin/tslint',
\])
endfunction
function! ale_linters#typescript#tslint#Handle(buffer, lines) abort function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
" Do not output any errors for empty files if the option is on. " Do not output any errors for empty files if the option is on.
@ -70,7 +60,7 @@ function! ale_linters#typescript#tslint#GetCommand(buffer) abort
\ : '' \ : ''
return ale#path#BufferCdString(a:buffer) return ale#path#BufferCdString(a:buffer)
\ . ale#Escape(ale_linters#typescript#tslint#GetExecutable(a:buffer)) \ . ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer))
\ . ' --format json' \ . ' --format json'
\ . l:tslint_config_option \ . l:tslint_config_option
\ . l:tslint_rules_option \ . l:tslint_rules_option
@ -79,7 +69,7 @@ endfunction
call ale#linter#Define('typescript', { call ale#linter#Define('typescript', {
\ 'name': 'tslint', \ 'name': 'tslint',
\ 'executable_callback': 'ale_linters#typescript#tslint#GetExecutable', \ 'executable_callback': 'ale#handlers#tslint#GetExecutable',
\ 'command_callback': 'ale_linters#typescript#tslint#GetCommand', \ 'command_callback': 'ale_linters#typescript#tslint#GetCommand',
\ 'callback': 'ale_linters#typescript#tslint#Handle', \ 'callback': 'ale_linters#typescript#tslint#Handle',
\}) \})

View File

@ -11,7 +11,7 @@ endfunction
function! ale_linters#xml#xmllint#GetCommand(buffer) abort function! ale_linters#xml#xmllint#GetCommand(buffer) abort
return ale#Escape(ale_linters#xml#xmllint#GetExecutable(a:buffer)) return ale#Escape(ale_linters#xml#xmllint#GetExecutable(a:buffer))
\ . ' ' . ale#Var(a:buffer, 'xml_xmllint_options') \ . ale#Pad(ale#Var(a:buffer, 'xml_xmllint_options'))
\ . ' --noout -' \ . ' --noout -'
endfunction endfunction

View File

@ -213,6 +213,25 @@ function! ale#Set(variable_name, default) abort
endif endif
endfunction endfunction
" Given a string for adding to a command, return the string padded with a
" space on the left if it is not empty. Otherwise return an empty string.
"
" This can be used for making command strings cleaner and easier to test.
function! ale#Pad(string) abort
return !empty(a:string) ? ' ' . a:string : ''
endfunction
" Given a environment variable name and a value, produce part of a command for
" setting an environment variable before running a command. The syntax will be
" valid for cmd on Windows, or most shells on Unix.
function! ale#Env(variable_name, value) abort
if has('win32')
return 'set ' . a:variable_name . '=' . ale#Escape(a:value) . ' && '
endif
return a:variable_name . '=' . ale#Escape(a:value) . ' '
endfunction
" Escape a string suitably for each platform. " Escape a string suitably for each platform.
" shellescape does not work on Windows. " shellescape does not work on Windows.
function! ale#Escape(str) abort function! ale#Escape(str) abort

View File

@ -1,3 +1,9 @@
let s:chain_results = []
function! ale#assert#WithChainResults(...) abort
let s:chain_results = a:000
endfunction
function! s:GetLinter() abort function! s:GetLinter() abort
let l:linters = ale#linter#GetLintersLoaded() let l:linters = ale#linter#GetLintersLoaded()
let l:filetype_linters = get(values(l:linters), 0, []) let l:filetype_linters = get(values(l:linters), 0, [])
@ -21,15 +27,31 @@ function! ale#assert#Linter(expected_executable, expected_command) abort
let l:executable = ale#linter#GetExecutable(l:buffer, l:linter) let l:executable = ale#linter#GetExecutable(l:buffer, l:linter)
if has_key(l:linter, 'command_chain') if has_key(l:linter, 'command_chain')
let l:command = [] let l:callbacks = map(copy(l:linter.command_chain), 'v:val.callback')
for l:chain_item in l:linter.command_chain " If the expected command is a string, just check the last one.
if empty(l:command) if type(a:expected_command) is type('')
call add(l:command, call(l:chain_item.callback, [l:buffer])) if len(l:callbacks) is 1
let l:command = call(l:callbacks[0], [l:buffer])
else else
call add(l:command, call(l:chain_item.callback, [l:buffer, []])) let l:input = get(s:chain_results, len(l:callbacks) - 2, [])
let l:command = call(l:callbacks[-1], [l:buffer, l:input])
endif endif
endfor else
let l:command = []
let l:chain_index = 0
for l:Callback in l:callbacks
if l:chain_index is 0
call add(l:command, call(l:Callback, [l:buffer]))
else
let l:input = get(s:chain_results, l:chain_index - 1, [])
call add(l:command, call(l:Callback, [l:buffer, l:input]))
endif
let l:chain_index += 1
endfor
endif
else else
let l:command = ale#linter#GetCommand(l:buffer, l:linter) let l:command = ale#linter#GetCommand(l:buffer, l:linter)
" Replace %e with the escaped executable, so tests keep passing after " Replace %e with the escaped executable, so tests keep passing after
@ -42,9 +64,96 @@ function! ale#assert#Linter(expected_executable, expected_command) abort
\ [l:executable, l:command] \ [l:executable, l:command]
endfunction endfunction
command! -nargs=+ AssertLinter :call ale#assert#Linter(<args>) function! ale#assert#LinterNotExecuted() abort
let l:buffer = bufnr('')
let l:linter = s:GetLinter()
let l:executable = ale#linter#GetExecutable(l:buffer, l:linter)
Assert empty(l:executable), "The linter will be executed when it shouldn't be"
endfunction
function! ale#assert#LSPOptions(expected_options) abort
let l:buffer = bufnr('')
let l:linter = s:GetLinter()
let l:initialization_options = ale#lsp_linter#GetOptions(l:buffer, l:linter)
AssertEqual a:expected_options, l:initialization_options
endfunction
function! ale#assert#LSPLanguage(expected_language) abort
let l:buffer = bufnr('')
let l:linter = s:GetLinter()
let l:language = ale#util#GetFunction(l:linter.language_callback)(l:buffer)
AssertEqual a:expected_language, l:language
endfunction
function! ale#assert#LSPProject(expected_root) abort
let l:buffer = bufnr('')
let l:linter = s:GetLinter()
let l:root = ale#util#GetFunction(l:linter.project_root_callback)(l:buffer)
AssertEqual a:expected_root, l:root
endfunction
" A dummy function for making sure this module is loaded. " A dummy function for making sure this module is loaded.
function! ale#assert#Init() abort function! ale#assert#SetUpLinterTest(filetype, name) abort
" Set up a marker so ALE doesn't create real random temporary filenames.
let g:ale_create_dummy_temporary_file = 1
" Remove current linters.
call ale#linter#Reset() call ale#linter#Reset()
call ale#linter#PreventLoading(a:filetype)
let l:prefix = 'ale_' . a:filetype . '_' . a:name
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
Save g:ale_c_build_dir
unlet! g:ale_c_build_dir
" Save and clear linter variables.
" We'll load the runtime file to reset them to defaults.
for l:key in filter(keys(g:), b:filter_expr)
execute 'Save g:' . l:key
unlet g:[l:key]
endfor
unlet! b:ale_c_build_dir
for l:key in filter(keys(b:), b:filter_expr)
unlet b:[l:key]
endfor
execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim'
call ale#test#SetDirectory('/testplugin/test/command_callback')
command! -nargs=+ WithChainResults :call ale#assert#WithChainResults(<args>)
command! -nargs=+ AssertLinter :call ale#assert#Linter(<args>)
command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted()
command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions(<args>)
command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage(<args>)
command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject(<args>)
endfunction
function! ale#assert#TearDownLinterTest() abort
unlet! g:ale_create_dummy_temporary_file
let s:chain_results = []
delcommand WithChainResults
delcommand AssertLinter
delcommand AssertLinterNotExecuted
delcommand AssertLSPOptions
delcommand AssertLSPLanguage
delcommand AssertLSPProject
call ale#test#RestoreDirectory()
Restore
call ale#linter#Reset()
if exists('*ale#semver#ResetVersionCache')
call ale#semver#ResetVersionCache()
endif
endfunction endfunction

View File

@ -96,8 +96,25 @@ function! ale#engine#ManageDirectory(buffer, directory) abort
call add(g:ale_buffer_info[a:buffer].temporary_directory_list, a:directory) call add(g:ale_buffer_info[a:buffer].temporary_directory_list, a:directory)
endfunction endfunction
function! ale#engine#CreateFile(buffer) abort
" This variable can be set to 1 in tests to stub this out.
if get(g:, 'ale_create_dummy_temporary_file')
return 'TEMP'
endif
let l:temporary_file = ale#util#Tempname()
call ale#engine#ManageFile(a:buffer, l:temporary_file)
return l:temporary_file
endfunction
" Create a new temporary directory and manage it in one go. " Create a new temporary directory and manage it in one go.
function! ale#engine#CreateDirectory(buffer) abort function! ale#engine#CreateDirectory(buffer) abort
" This variable can be set to 1 in tests to stub this out.
if get(g:, 'ale_create_dummy_temporary_file')
return 'TEMP_DIR'
endif
let l:temporary_directory = ale#util#Tempname() let l:temporary_directory = ale#util#Tempname()
" Create the temporary directory for the file, unreadable by 'other' " Create the temporary directory for the file, unreadable by 'other'
" users. " users.

View File

@ -2,7 +2,7 @@
" Description: Fixing files with tslint. " Description: Fixing files with tslint.
function! ale#fixers#tslint#Fix(buffer) abort function! ale#fixers#tslint#Fix(buffer) abort
let l:executable = ale_linters#typescript#tslint#GetExecutable(a:buffer) let l:executable = ale#handlers#tslint#GetExecutable(a:buffer)
let l:tslint_config_path = ale#path#ResolveLocalPath( let l:tslint_config_path = ale#path#ResolveLocalPath(
\ a:buffer, \ a:buffer,

View File

@ -1,6 +0,0 @@
call ale#Set('ruby_rails_best_practices_options', '')
call ale#Set('ruby_rails_best_practices_executable', 'rails_best_practices')
function! ale#handlers#rails_best_practices#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'ruby_rails_best_practices_executable')
endfunction

View File

@ -0,0 +1,13 @@
function! ale#handlers#tslint#InitVariables() abort
call ale#Set('typescript_tslint_executable', 'tslint')
call ale#Set('typescript_tslint_config_path', '')
call ale#Set('typescript_tslint_rules_dir', '')
call ale#Set('typescript_tslint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('typescript_tslint_ignore_empty_files', 0)
endfunction
function! ale#handlers#tslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [
\ 'node_modules/.bin/tslint',
\])
endfunction

View File

@ -114,6 +114,18 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
endif endif
endfunction endfunction
function! ale#lsp_linter#GetOptions(buffer, linter) abort
let l:initialization_options = {}
if has_key(a:linter, 'initialization_options_callback')
let l:initialization_options = ale#util#GetFunction(a:linter.initialization_options_callback)(a:buffer)
elseif has_key(a:linter, 'initialization_options')
let l:initialization_options = a:linter.initialization_options
endif
return l:initialization_options
endfunction
" Given a buffer, an LSP linter, and a callback to register for handling " Given a buffer, an LSP linter, and a callback to register for handling
" messages, start up an LSP linter and get ready to receive errors or " messages, start up an LSP linter and get ready to receive errors or
" completions. " completions.
@ -128,13 +140,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort
return {} return {}
endif endif
let l:initialization_options = {} let l:initialization_options = ale#lsp_linter#GetOptions(a:buffer, a:linter)
if has_key(a:linter, 'initialization_options_callback')
let l:initialization_options = ale#util#GetFunction(a:linter.initialization_options_callback)(a:buffer)
elseif has_key(a:linter, 'initialization_options')
let l:initialization_options = a:linter.initialization_options
endif
if a:linter.lsp is# 'socket' if a:linter.lsp is# 'socket'
let l:address = ale#linter#GetAddress(a:buffer, a:linter) let l:address = ale#linter#GetAddress(a:buffer, a:linter)

View File

@ -10,6 +10,7 @@ CONTENTS *ale-development-contents*
2. Design Goals.........................|ale-design-goals| 2. Design Goals.........................|ale-design-goals|
3. Coding Standards.....................|ale-coding-standards| 3. Coding Standards.....................|ale-coding-standards|
4. Testing ALE..........................|ale-development-tests| 4. Testing ALE..........................|ale-development-tests|
4.1. Writing Linter Tests.............|ale-development-linter-tests|
=============================================================================== ===============================================================================
1. Introduction *ale-development-introduction* 1. Introduction *ale-development-introduction*
@ -173,6 +174,9 @@ Look at existing tests in the codebase for examples of how to write tests.
Refer to the Vader documentation for general information on how to write Vader Refer to the Vader documentation for general information on how to write Vader
tests: https://github.com/junegunn/vader.vim tests: https://github.com/junegunn/vader.vim
See |ale-development-linter-tests| for more information on how to write linter
tests.
When you add new linters or fixers, make sure to add them into the table in When you add new linters or fixers, make sure to add them into the table in
the README, and also into the |ale-support| list in the main help file. If you the README, and also into the |ale-support| list in the main help file. If you
forget to keep them both in sync, you should see an error like the following forget to keep them both in sync, you should see an error like the following
@ -222,5 +226,82 @@ margin. For example, if you add a heading for an `aardvark` tool to
Make sure to make the table of contents match the headings, and to keep the Make sure to make the table of contents match the headings, and to keep the
doc tags on the right margin. doc tags on the right margin.
===============================================================================
4.1 Writing Linter Tests *ale-development-linter-tests*
Tests for ALE linters take two forms.
1. Tests for handling the output of commands.
2. Tests for checking which commands are run, or connections are made.
Tests of the first form should go in the `test/handler` directory, and should
be written like so. >
Before:
" Load the file which defines the linter.
runtime ale_linters/filetype/linter_name_here.vim
After:
" Unload all linters again.
call ale#linter#Reset()
Execute(The output should be correct):
" Test that the right loclist items are parsed from the handler.
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': 'Something went wrong',
\ },
\ ],
\ ale_linters#filetype#linter_name#Handle(bufnr(''), [
\ '1:Something went wrong',
\ ]
<
Tests for what ALE runs should go in the `test/command_callback` directory,
and should be written like so. >
Before:
" Load the linter and set up a series of commands, reset linter variables,
" clear caches, etc.
"
" Vader's 'Save' command will be called here for linter variables.
call ale#assert#SetUpLinterTest('filetype', 'linter_name')
After:
" Reset linters, variables, etc.
"
" Vader's 'Restore' command will be called here.
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
" AssertLinter checks the executable and command.
" Pass expected_executable, expected_command
AssertLinter 'some-command', ale#Escape('some-command') . ' --foo'
Execute(Check chained commands):
" WithChainResults can be called with 1 or more list for passing output
" to chained commands. The output for each callback defaults to an empty
" list.
WithChainResults ['v2.1.2']
" Given a List of commands, check all of them.
" Given a String, only the last command in the chain will be checked.
AssertLinter 'some-command', [
\ ale#Escape('some-command') . ' --version',
\ ale#Escape('some-command') . ' --foo',
\]
<
The full list of commands that will be temporarily defined for linter tests
given the above setup are as follows.
`WithChainResults [...]` - Define output for command chain functions.
`AssertLinter executable, command` - Check the executable and command.
`AssertLinterNotExecuted` - Check that linters will not be executed.
`AssertLSPLanguage language` - Check the language given to an LSP server.
`AssertLSPOptions options_dict` - Check the options given to an LSP server.
`AssertLSPProject project_root` - Check the root given to an LSP server.
=============================================================================== ===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -41,8 +41,8 @@ To disable `scalastyle` globally, use |g:ale_linters| like so: >
See |g:ale_linters| for more information on disabling linters. See |g:ale_linters| for more information on disabling linters.
g:ale_scalastyle_config_loc *g:ale_scalastyle_config_loc* g:ale_scala_scalastyle_config *g:ale_scala_scalastyle_config*
*b:ale_scala_scalastyle_config*
Type: |String| Type: |String|
Default: `''` Default: `''`
@ -54,7 +54,7 @@ g:ale_scalastyle_config_loc *g:ale_scalastyle_config_loc*
g:ale_scala_scalastyle_options *g:ale_scala_scalastyle_options* g:ale_scala_scalastyle_options *g:ale_scala_scalastyle_options*
*b:ale_scala_scalastyle_options*
Type: |String| Type: |String|
Default: `''` Default: `''`

View File

@ -2074,6 +2074,29 @@ ALEStopAllLSPs *ALEStopAllLSPs*
=============================================================================== ===============================================================================
9. API *ale-api* 9. API *ale-api*
ALE offers a number of functions for running linters or fixers, or defining
them. The following functions are part of the publicly documented part of that
API, and should be expected to continue to work.
ale#Env(variable_name, value) *ale#Env()*
Given a variable name and a string value, produce a string for including in
a command for setting environment variables. This function can be used for
building a command like so. >
:echo string(ale#Env('VAR', 'some value') . 'command')
'VAR=''some value'' command' # On Linux or Mac OSX
'set VAR="some value" && command' # On Windows
ale#Pad(string) *ale#Pad()*
Given a string or any |empty()| value, return either the string prefixed
with a single space, or an empty string. This function can be used to build
parts of a command from variables.
ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()* ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()*
Run linters for the current buffer, based on the filetype of the buffer, Run linters for the current buffer, based on the filetype of the buffer,
@ -2098,8 +2121,17 @@ ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()*
ale#engine#CreateDirectory(buffer) *ale#engine#CreateDirectory()* ale#engine#CreateDirectory(buffer) *ale#engine#CreateDirectory()*
Create a new temporary directory with a unique name, and manage that Create a new temporary directory with a unique name, and manage that
directory with |ale#engine#ManageDirectory()|, so it will be removed as directory with |ale#engine#ManageDirectory()|, so it will be removed as soon
soon as possible. as possible.
It is advised to only call this function from a callback function for
returning a linter command to run.
ale#engine#CreateFile(buffer) *ale#engine#CreateFile()*
Create a new temporary file with a unique name, and manage that file with
|ale#engine#ManageFile()|, so it will be removed as soon as possible.
It is advised to only call this function from a callback function for It is advised to only call this function from a callback function for
returning a linter command to run. returning a linter command to run.

View File

@ -149,13 +149,18 @@ failed=0
index=0 index=0
for pid in $pid_list; do for pid in $pid_list; do
this_failed=0
index=$((index+1)) index=$((index+1))
if ! wait "$pid"; then if ! wait "$pid"; then
failed=1 failed=1
this_failed=1
fi fi
cat "$output_dir/$index" # Hide output for things that passed if -q is set.
if [ "$quiet_flag" != '-q' ] || ((this_failed)); then
cat "$output_dir/$index"
fi
done done
if ((failed)); then if ((failed)); then

View File

@ -1,39 +1,18 @@
Before: Before:
Save g:ale_asm_gcc_executable call ale#assert#SetUpLinterTest('asm', 'gcc')
Save g:ale_asm_gcc_options call ale#test#SetFilename('test.cpp')
unlet! g:ale_asm_gcc_executable
unlet! b:ale_asm_gcc_executable
unlet! g:ale_asm_gcc_options
unlet! b:ale_asm_gcc_options
runtime ale_linters/asm/gcc.vim
let b:command_tail = ' -x assembler -fsyntax-only -iquote' let b:command_tail = ' -x assembler -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd()) \ . ' ' . ale#Escape(g:dir)
\ . ' -Wall -' \ . ' -Wall -'
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_asm_gcc_executable
unlet! b:ale_asm_gcc_options call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'gcc', ale_linters#asm#gcc#GetExecutable(bufnr('')) AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
let b:ale_asm_gcc_executable = 'foobar' let b:ale_asm_gcc_executable = 'foobar'
AssertEqual 'foobar', ale_linters#asm#gcc#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('gcc') . b:command_tail,
\ ale_linters#asm#gcc#GetCommand(bufnr(''))
let b:ale_asm_gcc_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#asm#gcc#GetCommand(bufnr(''))

View File

@ -1,39 +1,24 @@
Before: Before:
Save g:ale_ruby_brakeman_options call ale#assert#SetUpLinterTest('ruby', 'brakeman')
runtime ale_linters/ruby/brakeman.vim
let g:ale_ruby_brakeman_options = ''
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The brakeman command callback should detect absence of a valid Rails app): Execute(The brakeman command callback should detect absence of a valid Rails app):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/test.rb') call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/test.rb')
AssertEqual AssertLinter 'brakeman', ''
\ '',
\ ale_linters#ruby#brakeman#GetCommand(bufnr(''))
Execute(The brakeman command callback should find a valid Rails app root): Execute(The brakeman command callback should find a valid Rails app root):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb')
AssertEqual AssertLinter 'brakeman', 'brakeman -f json -q -p '
\ 'brakeman -f json -q -p ' \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app'))
\ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app')),
\ ale_linters#ruby#brakeman#GetCommand(bufnr(''))
Execute(The brakeman command callback should include configured options): Execute(The brakeman command callback should include configured options):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb')
let g:ale_ruby_brakeman_options = '--combobulate' let g:ale_ruby_brakeman_options = '--combobulate'
AssertEqual AssertLinter 'brakeman', 'brakeman -f json -q --combobulate -p '
\ 'brakeman -f json -q --combobulate -p ' \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app'))
\ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app')),
\ ale_linters#ruby#brakeman#GetCommand(bufnr(''))

View File

@ -1,39 +1,17 @@
Before: Before:
Save g:ale_c_clang_executable call ale#assert#SetUpLinterTest('c', 'clang')
Save g:ale_c_clang_options
unlet! g:ale_c_clang_executable
unlet! b:ale_c_clang_executable
unlet! g:ale_c_clang_options
unlet! b:ale_c_clang_options
runtime ale_linters/c/clang.vim
let b:command_tail = ' -S -x c -fsyntax-only -iquote' let b:command_tail = ' -S -x c -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd()) \ . ' ' . ale#Escape(getcwd())
\ . ' -std=c11 -Wall -' \ . ' -std=c11 -Wall -'
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_c_clang_executable
unlet! b:ale_c_clang_options call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'clang', ale_linters#c#clang#GetExecutable(bufnr('')) AssertLinter 'clang', ['', ale#Escape('clang') . b:command_tail]
let b:ale_c_clang_executable = 'foobar' let b:ale_c_clang_executable = 'foobar'
AssertEqual 'foobar', ale_linters#c#clang#GetExecutable(bufnr('')) AssertLinter 'foobar', ['', ale#Escape('foobar') . b:command_tail]
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('clang') . b:command_tail,
\ ale_linters#c#clang#GetCommand(bufnr(''), [])
let b:ale_c_clang_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#c#clang#GetCommand(bufnr(''), [])

View File

@ -1,77 +1,49 @@
Before: Before:
Save g:ale_c_clangtidy_checks call ale#assert#SetUpLinterTest('c', 'clangtidy')
Save g:ale_c_clangtidy_options
Save g:ale_c_build_dir
unlet! g:ale_c_build_dir
unlet! b:ale_c_build_dir
unlet! g:ale_c_clangtidy_checks
unlet! b:ale_c_clangtidy_checks
unlet! g:ale_c_clangtidy_options
unlet! b:ale_c_clangtidy_options
runtime ale_linters/c/clangtidy.vim
call ale#test#SetFilename('test.c') call ale#test#SetFilename('test.c')
After: After:
unlet! b:ale_c_build_dir call ale#assert#TearDownLinterTest()
unlet! b:ale_c_clangtidy_checks
unlet! b:ale_c_clangtidy_options
unlet! b:ale_c_clangtidy_executable
Restore
call ale#linter#Reset()
Execute(The clangtidy command default should be correct): Execute(The clangtidy command default should be correct):
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to remove the -checks option for clang-tidy): Execute(You should be able to remove the -checks option for clang-tidy):
let b:ale_c_clangtidy_checks = [] let b:ale_c_clangtidy_checks = []
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' %s'
\ . ' %s',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to set other checks for clang-tidy): Execute(You should be able to set other checks for clang-tidy):
let b:ale_c_clangtidy_checks = ['-*', 'clang-analyzer-*'] let b:ale_c_clangtidy_checks = ['-*', 'clang-analyzer-*']
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s', \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s'
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to manually set compiler flags for clang-tidy): Execute(You should be able to manually set compiler flags for clang-tidy):
let b:ale_c_clangtidy_options = '-Wall' let b:ale_c_clangtidy_options = '-Wall'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
\ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -- -Wall',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
\
Execute(The build directory should be configurable): Execute(The build directory should be configurable):
let b:ale_c_build_dir = '/foo/bar' let b:ale_c_build_dir = '/foo/bar'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s' \ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -p ' . ale#Escape('/foo/bar'), \ . ' -p ' . ale#Escape('/foo/bar')
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(The build directory setting should override the options): Execute(The build directory setting should override the options):
let b:ale_c_build_dir = '/foo/bar' let b:ale_c_build_dir = '/foo/bar'
let b:ale_c_clangtidy_options = '-Wall' let b:ale_c_clangtidy_options = '-Wall'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s' \ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -p ' . ale#Escape('/foo/bar'), \ . ' -p ' . ale#Escape('/foo/bar')
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(The build directory should be ignored for header files): Execute(The build directory should be ignored for header files):
call ale#test#SetFilename('test.h') call ale#test#SetFilename('test.h')
@ -79,24 +51,17 @@ Execute(The build directory should be ignored for header files):
let b:ale_c_build_dir = '/foo/bar' let b:ale_c_build_dir = '/foo/bar'
let b:ale_c_clangtidy_options = '-Wall' let b:ale_c_clangtidy_options = '-Wall'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s' \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
\ . ' -- -Wall',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
\
call ale#test#SetFilename('test.h') call ale#test#SetFilename('test.h')
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
\ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -- -Wall',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(The executable should be configurable): Execute(The executable should be configurable):
let b:ale_c_clangtidy_executable = 'foobar' let b:ale_c_clangtidy_executable = 'foobar'
AssertEqual AssertLinter 'foobar',
\ ale#Escape('foobar') \ ale#Escape('foobar') . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))

View File

@ -1,49 +1,24 @@
Before: Before:
Save g:ale_c_cppcheck_executable call ale#assert#SetUpLinterTest('c', 'cppcheck')
Save g:ale_c_cppcheck_options
unlet! g:ale_c_cppcheck_executable
unlet! b:ale_c_cppcheck_executable
unlet! g:ale_c_cppcheck_options
unlet! b:ale_c_cppcheck_options
runtime ale_linters/c/cppcheck.vim
let b:command_tail = ' -q --language=c --enable=style %t' let b:command_tail = ' -q --language=c --enable=style %t'
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_c_cppcheck_executable
unlet! b:ale_c_cppcheck_options
call ale#linter#Reset()
call ale#test#RestoreDirectory()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'cppcheck', ale_linters#c#cppcheck#GetExecutable(bufnr('')) AssertLinter 'cppcheck', ale#Escape('cppcheck') . b:command_tail
let b:ale_c_cppcheck_executable = 'foobar' let b:ale_c_cppcheck_executable = 'foobar'
AssertEqual 'foobar', ale_linters#c#cppcheck#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('cppcheck') . b:command_tail,
\ ale_linters#c#cppcheck#GetCommand(bufnr(''))
let b:ale_c_cppcheck_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#c#cppcheck#GetCommand(bufnr(''))
Execute(cppcheck for C++ should detect compile_commands.json files): Execute(cppcheck for C++ should detect compile_commands.json files):
call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') call ale#test#SetFilename('cppcheck_paths/one/foo.cpp')
AssertEqual AssertLinter 'cppcheck',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && ' \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && '
\ . ale#Escape('cppcheck') \ . ale#Escape('cppcheck')
\ . ' -q --language=c --project=compile_commands.json --enable=style %t', \ . ' -q --language=c --project=compile_commands.json --enable=style %t'
\ ale_linters#c#cppcheck#GetCommand(bufnr(''))

View File

@ -1,51 +1,24 @@
Before: Before:
Save g:ale_c_flawfinder_executable call ale#assert#SetUpLinterTest('c', 'flawfinder')
Save g:ale_c_flawfinder_options
Save g:ale_c_flawfinder_minlevel
unlet! g:ale_c_flawfinder_executable
unlet! b:ale_c_flawfinder_executable
unlet! g:ale_c_flawfinder_options
unlet! b:ale_c_flawfinder_options
unlet! g:ale_c_flawfinder_minlevel
unlet! b:ale_c_flawfinder_minlevel
runtime ale_linters/c/flawfinder.vim
After: After:
unlet! b:ale_c_flawfinder_executable call ale#assert#TearDownLinterTest()
unlet! b:ale_c_flawfinder_options
unlet! b:ale_c_flawfinder_minlevel
Restore
call ale#linter#Reset()
Execute(The flawfinder command should be correct): Execute(The flawfinder command should be correct):
AssertEqual AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=1 %t'
\ ale#Escape('flawfinder')
\ . ' -CDQS --minlevel=1 %t',
\ ale_linters#c#flawfinder#GetCommand(bufnr(''))
Execute(The minlevel of flawfinder should be configurable): Execute(The minlevel of flawfinder should be configurable):
let b:ale_c_flawfinder_minlevel = 8 let b:ale_c_flawfinder_minlevel = 8
AssertEqual AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t'
\ ale#Escape('flawfinder')
\ . ' -CDQS --minlevel=8 %t',
\ ale_linters#c#flawfinder#GetCommand(bufnr(''))
Execute(Additional flawfinder options should be configurable): Execute(Additional flawfinder options should be configurable):
let b:ale_c_flawfinder_options = ' --foobar' let b:ale_c_flawfinder_options = ' --foobar'
AssertEqual AssertLinter 'flawfinder',
\ ale#Escape('flawfinder') \ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t'
\ . ' -CDQS --foobar --minlevel=1 %t',
\ ale_linters#c#flawfinder#GetCommand(bufnr(''))
Execute(The flawfinder exectable should be configurable): Execute(The flawfinder exectable should be configurable):
let b:ale_c_flawfinder_executable = 'foo/bar' let b:ale_c_flawfinder_executable = 'foo/bar'
AssertEqual AssertLinter 'foo/bar', ale#Escape('foo/bar') . ' -CDQS --minlevel=1 %t'
\ ale#Escape('foo/bar')
\ . ' -CDQS --minlevel=1 %t',
\ ale_linters#c#flawfinder#GetCommand(bufnr(''))

View File

@ -1,39 +1,18 @@
Before: Before:
Save g:ale_c_gcc_executable call ale#assert#SetUpLinterTest('c', 'gcc')
Save g:ale_c_gcc_options
unlet! g:ale_c_gcc_executable
unlet! b:ale_c_gcc_executable
unlet! g:ale_c_gcc_options
unlet! b:ale_c_gcc_options
runtime ale_linters/c/gcc.vim
let b:command_tail = ' -S -x c -fsyntax-only -iquote' let b:command_tail = ' -S -x c -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd()) \ . ' ' . ale#Escape(getcwd())
\ . ' -std=c11 -Wall -' \ . ' -std=c11 -Wall -'
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_c_gcc_executable
unlet! b:ale_c_gcc_options
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'gcc', ale_linters#c#gcc#GetExecutable(bufnr('')) AssertLinter 'gcc', ['', ale#Escape('gcc') . b:command_tail]
let b:ale_c_gcc_executable = 'foobar' let b:ale_c_gcc_executable = 'foobar'
AssertEqual 'foobar', ale_linters#c#gcc#GetExecutable(bufnr('')) AssertLinter 'foobar', ['', ale#Escape('foobar') . b:command_tail]
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('gcc') . b:command_tail,
\ ale_linters#c#gcc#GetCommand(bufnr(''), [])
let b:ale_c_gcc_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#c#gcc#GetCommand(bufnr(''), [])

View File

@ -1,223 +1,130 @@
Before: Before:
Save g:ale_rust_cargo_use_check call ale#assert#SetUpLinterTest('rust', 'cargo')
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
Save g:ale_rust_cargo_avoid_whole_workspace
unlet! g:ale_rust_cargo_use_check
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
unlet! g:ale_rust_cargo_avoid_whole_workspace
runtime ale_linters/rust/cargo.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
let g:suffix = ' --frozen --message-format=json -q' let g:suffix = ' --frozen --message-format=json -q'
" Test with version 0.22.0 by default.
WithChainResults ['cargo 0.22.0 (3423351a5 2017-10-06)']
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! g:suffix unlet! g:suffix
call ale#test#RestoreDirectory() Execute(The linter should not be executed when there's no Cargo.toml file):
call ale#linter#Reset() AssertLinterNotExecuted
call ale#semver#ResetVersionCache()
Execute(An empty string should be returned for the cargo executable when there's no Cargo.toml file): Execute(The linter should be executed when there is a Cargo.toml file):
AssertEqual
\ '',
\ ale_linters#rust#cargo#GetCargoExecutable(bufnr(''))
Execute(The executable should be returned when there is a Cargo.toml file):
call ale#test#SetFilename('cargo_paths/test.rs') call ale#test#SetFilename('cargo_paths/test.rs')
AssertEqual WithChainResults []
\ 'cargo', AssertLinter 'cargo',
\ ale_linters#rust#cargo#GetCargoExecutable(bufnr('')) \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cargo_paths')) . ' && '
\ . 'cargo build --frozen --message-format=json -q'
Execute(The VersionCheck function should return the --version command):
AssertEqual
\ 'cargo --version',
\ ale_linters#rust#cargo#VersionCheck(bufnr(''))
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual WithChainResults []
\ 'cargo build' . g:suffix, AssertLinter '', ['cargo --version', 'cargo build' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
Execute(`cargo check` should be used when the version is new enough): Execute(`cargo check` should be used when the version is new enough):
AssertEqual WithChainResults ['cargo 0.17.0 (3423351a5 2017-10-06)']
\ 'cargo check' . g:suffix, AssertLinter '', ['cargo --version', 'cargo check' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.17.0 (3423351a5 2017-10-06)',
\ ])
" We should cache the version check " We should cache the version check
AssertEqual WithChainResults []
\ 'cargo check' . g:suffix, AssertLinter '', ['', 'cargo check' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
Execute(`cargo build` should be used when cargo is too old): Execute(`cargo build` should be used when cargo is too old):
AssertEqual WithChainResults ['cargo 0.16.0 (3423351a5 2017-10-06)']
\ 'cargo build' . g:suffix, AssertLinter '', ['cargo --version', 'cargo build' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.16.0 (3423351a5 2017-10-06)',
\ ])
" We should cache the version check WithChainResults []
AssertEqual AssertLinter '', ['', 'cargo build' . g:suffix]
\ 'cargo build' . g:suffix,
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
Execute(`cargo build` should be used when g:ale_rust_cargo_use_check is set to 0): Execute(`cargo build` should be used when g:ale_rust_cargo_use_check is set to 0):
let g:ale_rust_cargo_use_check = 0 let g:ale_rust_cargo_use_check = 0
AssertEqual WithChainResults ['cargo 0.24.0 (3423351a5 2017-10-06)']
\ 'cargo build' . g:suffix, AssertLinter '', ['cargo --version', 'cargo build' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.24.0 (3423351a5 2017-10-06)',
\ ])
" We should cache the version check " We should cache the version check
AssertEqual WithChainResults []
\ 'cargo build' . g:suffix, AssertLinter '', ['', 'cargo build' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
Execute(`cargo check` should be used when the version is new enough): Execute(`cargo check` should be used when the version is new enough):
AssertEqual AssertLinter '', ['cargo --version', 'cargo check' . g:suffix]
\ 'cargo check' . g:suffix,
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
" We should cache the version check " We should cache the version check
AssertEqual WithChainResults []
\ 'cargo check' . g:suffix, AssertLinter '', ['', 'cargo check' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
Execute(--all-targets should be used when g:ale_rust_cargo_check_all_targets is set to 1): Execute(--all-targets should be used when g:ale_rust_cargo_check_all_targets is set to 1):
let g:ale_rust_cargo_check_all_targets = 1 let g:ale_rust_cargo_check_all_targets = 1
AssertEqual AssertLinter '', ['cargo --version', 'cargo check --all-targets' . g:suffix]
\ 'cargo check --all-targets' . g:suffix,
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
" We should cache the version check " We should cache the version check
AssertEqual WithChainResults []
\ 'cargo check --all-targets' . g:suffix, AssertLinter '', ['', 'cargo check --all-targets' . g:suffix]
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
Execute(--tests should be used when g:ale_rust_cargo_check_tests is set to 1): Execute(--tests should be used when g:ale_rust_cargo_check_tests is set to 1):
let g:ale_rust_cargo_check_tests = 1 let g:ale_rust_cargo_check_tests = 1
AssertEqual AssertLinter '', ['cargo --version', 'cargo check --tests' . g:suffix]
\ '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 " We should cache the version check
AssertEqual WithChainResults []
\ 'cargo check --tests' . g:suffix, AssertLinter '', ['', '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): Execute(--examples should be used when g:ale_rust_cargo_check_examples is set to 1):
let g:ale_rust_cargo_check_examples = 1 let g:ale_rust_cargo_check_examples = 1
AssertEqual AssertLinter '', ['cargo --version', 'cargo check --examples' . g:suffix]
\ '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 " We should cache the version check
AssertEqual WithChainResults []
\ 'cargo check --examples' . g:suffix, AssertLinter '', ['', '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): 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' let b:ale_rust_cargo_default_feature_behavior = 'none'
AssertEqual AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --no-default-features']
\ 'cargo check' . g:suffix . ' --no-default-features',
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
Execute(g:ale_rust_cargo_include_features added when g:ale_rust_cargo_default_feature_behavior is none): Execute(g:ale_rust_cargo_include_features added when g:ale_rust_cargo_default_feature_behavior is none):
let g:ale_rust_cargo_default_feature_behavior = 'none' let b:ale_rust_cargo_default_feature_behavior = 'none'
let g:ale_rust_cargo_include_features = 'foo bar' let b:ale_rust_cargo_include_features = 'foo bar'
AssertEqual AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --no-default-features --features ' . ale#Escape('foo bar')]
\ 'cargo check' . g:suffix . ' --no-default-features --features ' .
\ (fnamemodify(&shell, ':t') is? 'cmd.exe' ? '"foo bar"' : "'foo bar'"),
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
Execute(g:ale_rust_cargo_include_features added and escaped): Execute(g:ale_rust_cargo_include_features added and escaped):
let g:ale_rust_cargo_default_feature_behavior = 'default' let b:ale_rust_cargo_default_feature_behavior = 'default'
let g:ale_rust_cargo_include_features = "foo bar baz" let b:ale_rust_cargo_include_features = "foo bar baz"
AssertEqual AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --features ' . ale#Escape('foo bar baz')]
\ 'cargo check' . g:suffix . ' --features ' .
\ (fnamemodify(&shell, ':t') is? 'cmd.exe' ? '"foo bar baz"' : "'foo bar baz'"),
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
Execute(--all-features should be used when g:ale_rust_cargo_default_feature_behavior is all): Execute(--all-features should be used when g:ale_rust_cargo_default_feature_behavior is all):
let g:ale_rust_cargo_default_feature_behavior = 'all' let b:ale_rust_cargo_default_feature_behavior = 'all'
" When all features are enabled we should ignore extra features to add " When all features are enabled we should ignore extra features to add
" since it won't do anything " since it won't do anything
let g:ale_rust_cargo_include_features = 'foo bar' let b:ale_rust_cargo_include_features = 'foo bar'
AssertEqual WithChainResults ['cargo 0.22.0 (3423351a5 2017-10-06)']
\ 'cargo check' . g:suffix . ' --all-features', AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --all-features']
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
Execute(When a crate belongs to a workspace we chdir into the crate.): Execute(When a crate belongs to a workspace we should cd into the crate):
call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs') call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs')
if ale#Has('win32') AssertLinter 'cargo', [
let test_cdprefix = "C:\\testplugin\\test\\command_callback\\cargo_workspace_paths\\subpath" \ 'cargo --version',
else \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cargo_workspace_paths/subpath')) . ' && '
let test_cdprefix = "'/testplugin/test/command_callback/cargo_workspace_paths/subpath'" \ . 'cargo check --frozen --message-format=json -q',
endif \]
AssertEqual
\ "cd ".test_cdprefix." && cargo build --frozen --message-format=json -q",
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
Execute(When a crate belongs to a workspace we chdir into the crate, unless we disabled it): Execute(When a crate belongs to a workspace we chdir into the crate, unless we disabled it):
let g:ale_rust_cargo_avoid_whole_workspace = 0 let g:ale_rust_cargo_avoid_whole_workspace = 0
call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs') call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs')
AssertEqual AssertLinter 'cargo', [
\ "cargo build --frozen --message-format=json -q", \ 'cargo --version',
\ ale_linters#rust#cargo#GetCommand(bufnr(''), []) \ 'cargo check --frozen --message-format=json -q',
\]

View File

@ -1,74 +1,46 @@
Before: Before:
Save g:ale_cpp_clangtidy_checks call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
Save g:ale_cpp_clangtidy_options
Save g:ale_c_build_dir
unlet! g:ale_c_build_dir
unlet! b:ale_c_build_dir
unlet! g:ale_cpp_clangtidy_checks
unlet! b:ale_cpp_clangtidy_checks
unlet! g:ale_cpp_clangtidy_options
unlet! b:ale_cpp_clangtidy_options
runtime ale_linters/cpp/clangtidy.vim
call ale#test#SetFilename('test.cpp') call ale#test#SetFilename('test.cpp')
After: After:
unlet! b:ale_c_build_dir call ale#assert#TearDownLinterTest()
unlet! b:ale_cpp_clangtidy_checks
unlet! b:ale_cpp_clangtidy_options
unlet! b:ale_cpp_clangtidy_executable
Restore
call ale#linter#Reset()
Execute(The clangtidy command default should be correct): Execute(The clangtidy command default should be correct):
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to remove the -checks option for clang-tidy): Execute(You should be able to remove the -checks option for clang-tidy):
let b:ale_cpp_clangtidy_checks = [] let b:ale_cpp_clangtidy_checks = []
AssertEqual AssertLinter 'clang-tidy', ale#Escape('clang-tidy') . ' %s'
\ ale#Escape('clang-tidy')
\ . ' %s',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to set other checks for clang-tidy): Execute(You should be able to set other checks for clang-tidy):
let b:ale_cpp_clangtidy_checks = ['-*', 'clang-analyzer-*'] let b:ale_cpp_clangtidy_checks = ['-*', 'clang-analyzer-*']
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s', \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s'
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to manually set compiler flags for clang-tidy): Execute(You should be able to manually set compiler flags for clang-tidy):
let b:ale_cpp_clangtidy_options = '-Wall' let b:ale_cpp_clangtidy_options = '-Wall'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
\ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
\ \
Execute(The build directory should be configurable): Execute(The build directory should be configurable):
let b:ale_c_build_dir = '/foo/bar' let b:ale_c_build_dir = '/foo/bar'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar'), \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar')
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(The build directory setting should override the options): Execute(The build directory setting should override the options):
let b:ale_c_build_dir = '/foo/bar' let b:ale_c_build_dir = '/foo/bar'
let b:ale_cpp_clangtidy_options = '-Wall' let b:ale_cpp_clangtidy_options = '-Wall'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar'), \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar')
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(The build directory should be ignored for header files): Execute(The build directory should be ignored for header files):
call ale#test#SetFilename('test.h') call ale#test#SetFilename('test.h')
@ -76,22 +48,16 @@ Execute(The build directory should be ignored for header files):
let b:ale_c_build_dir = '/foo/bar' let b:ale_c_build_dir = '/foo/bar'
let b:ale_cpp_clangtidy_options = '-Wall' let b:ale_cpp_clangtidy_options = '-Wall'
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
\ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
\
call ale#test#SetFilename('test.hpp') call ale#test#SetFilename('test.hpp')
AssertEqual AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
\ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(The executable should be configurable): Execute(The executable should be configurable):
let b:ale_cpp_clangtidy_executable = 'foobar' let b:ale_cpp_clangtidy_executable = 'foobar'
AssertEqual AssertLinter 'foobar',
\ ale#Escape('foobar') \ ale#Escape('foobar') . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))

View File

@ -1,39 +1,16 @@
Before: Before:
Save g:ale_cpp_clang_executable call ale#assert#SetUpLinterTest('cpp', 'clang')
Save g:ale_cpp_clang_options
unlet! g:ale_cpp_clang_executable
unlet! b:ale_cpp_clang_executable
unlet! g:ale_cpp_clang_options
unlet! b:ale_cpp_clang_options
runtime ale_linters/cpp/clang.vim
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote' let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd()) \ . ' ' . ale#Escape(getcwd())
\ . ' -std=c++14 -Wall -' \ . ' -std=c++14 -Wall -'
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_cpp_clang_executable call ale#assert#TearDownLinterTest()
unlet! b:ale_cpp_clang_options
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'clang++', ale_linters#cpp#clang#GetExecutable(bufnr('')) AssertLinter 'clang++', ale#Escape('clang++') . b:command_tail
let b:ale_cpp_clang_executable = 'foobar' let b:ale_cpp_clang_executable = 'foobar'
AssertEqual 'foobar', ale_linters#cpp#clang#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('clang++') . b:command_tail,
\ ale_linters#cpp#clang#GetCommand(bufnr(''), [])
let b:ale_cpp_clang_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#cpp#clang#GetCommand(bufnr(''), [])

View File

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

View File

@ -1,49 +1,22 @@
Before: Before:
Save g:ale_cpp_cppcheck_executable call ale#assert#SetUpLinterTest('cpp', 'cppcheck')
Save g:ale_cpp_cppcheck_options
unlet! g:ale_cpp_cppcheck_executable
unlet! b:ale_cpp_cppcheck_executable
unlet! g:ale_cpp_cppcheck_options
unlet! b:ale_cpp_cppcheck_options
runtime ale_linters/cpp/cppcheck.vim
let b:command_tail = ' -q --language=c++ --enable=style %t' let b:command_tail = ' -q --language=c++ --enable=style %t'
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_cpp_cppcheck_executable call ale#assert#TearDownLinterTest()
unlet! b:ale_cpp_cppcheck_options
call ale#linter#Reset()
call ale#test#RestoreDirectory()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'cppcheck', ale_linters#cpp#cppcheck#GetExecutable(bufnr('')) AssertLinter 'cppcheck', ale#Escape('cppcheck') . b:command_tail
let b:ale_cpp_cppcheck_executable = 'foobar' let b:ale_cpp_cppcheck_executable = 'foobar'
AssertEqual 'foobar', ale_linters#cpp#cppcheck#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('cppcheck') . b:command_tail,
\ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))
let b:ale_cpp_cppcheck_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))
Execute(cppcheck for C++ should detect compile_commands.json files): Execute(cppcheck for C++ should detect compile_commands.json files):
call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') call ale#test#SetFilename('cppcheck_paths/one/foo.cpp')
AssertEqual AssertLinter 'cppcheck',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && ' \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && '
\ . ale#Escape('cppcheck') \ . ale#Escape('cppcheck')
\ . ' -q --language=c++ --project=compile_commands.json --enable=style %t', \ . ' -q --language=c++ --project=compile_commands.json --enable=style %t'
\ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))

View File

@ -2,47 +2,21 @@
" Description: A language server for C++ " Description: A language server for C++
Before: Before:
Save g:ale_cpp_cquery_executable call ale#assert#SetUpLinterTest('cpp', 'cquery')
Save g:ale_cpp_cquery_cache_directory
unlet! g:ale_cpp_cquery_executable
unlet! b:ale_cpp_cquery_executable
unlet! g:ale_cpp_cquery_cache_directory
unlet! b:ale_cpp_cquery_cache_directory
runtime ale_linters/cpp/cquery.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:ale_cpp_cquery_executable
unlet! b:ale_cpp_cquery_cache_directory
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'cquery', ale_linters#cpp#cquery#GetExecutable(bufnr('')) AssertLinter 'cquery', ale#Escape('cquery')
let b:ale_cpp_cquery_executable = 'foobar' let b:ale_cpp_cquery_executable = 'foobar'
AssertEqual 'foobar', ale_linters#cpp#cquery#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar')
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('cquery'),
\ ale_linters#cpp#cquery#GetCommand(bufnr(''))
let b:ale_cpp_cquery_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar'),
\ ale_linters#cpp#cquery#GetCommand(bufnr(''))
Execute(The cache directory should be configurable): Execute(The cache directory should be configurable):
AssertEqual AssertLSPOptions {'cacheDirectory': expand('$HOME/.cache/cquery')}
\ {'cacheDirectory': expand('$HOME/.cache/cquery')},
\ ale_linters#cpp#cquery#GetInitializationOptions(bufnr(''))
let b:ale_cpp_cquery_cache_directory = '/foo/bar' let b:ale_cpp_cquery_cache_directory = '/foo/bar'
AssertEqual AssertLSPOptions {'cacheDirectory': '/foo/bar'}
\ {'cacheDirectory': '/foo/bar'},
\ ale_linters#cpp#cquery#GetInitializationOptions(bufnr(''))

View File

@ -1,51 +1,26 @@
Before: Before:
Save g:ale_cpp_flawfinder_executable call ale#assert#SetUpLinterTest('cpp', 'flawfinder')
Save g:ale_cpp_flawfinder_options
Save g:ale_cpp_flawfinder_minlevel
unlet! g:ale_cpp_flawfinder_executable
unlet! b:ale_cpp_flawfinder_executable
unlet! g:ale_cpp_flawfinder_options
unlet! b:ale_cpp_flawfinder_options
unlet! g:ale_cpp_flawfinder_minlevel
unlet! b:ale_cpp_flawfinder_minlevel
runtime ale_linters/cpp/flawfinder.vim
After: After:
unlet! b:ale_cpp_flawfinder_executable call ale#assert#TearDownLinterTest()
unlet! b:ale_cpp_flawfinder_options
unlet! b:ale_cpp_flawfinder_minlevel
Restore
call ale#linter#Reset()
Execute(The flawfinder command should be correct): Execute(The flawfinder command should be correct):
AssertEqual AssertLinter 'flawfinder',
\ ale#Escape('flawfinder') \ ale#Escape('flawfinder') . ' -CDQS --minlevel=1 %t'
\ . ' -CDQS --minlevel=1 %t',
\ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))
Execute(The minlevel of flawfinder should be configurable): Execute(The minlevel of flawfinder should be configurable):
let b:ale_cpp_flawfinder_minlevel = 8 let b:ale_cpp_flawfinder_minlevel = 8
AssertEqual AssertLinter 'flawfinder',
\ ale#Escape('flawfinder') \ ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t'
\ . ' -CDQS --minlevel=8 %t',
\ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))
Execute(Additional flawfinder options should be configurable): Execute(Additional flawfinder options should be configurable):
let b:ale_cpp_flawfinder_options = ' --foobar' let b:ale_cpp_flawfinder_options = ' --foobar'
AssertEqual AssertLinter 'flawfinder',
\ ale#Escape('flawfinder') \ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t'
\ . ' -CDQS --foobar --minlevel=1 %t',
\ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))
Execute(The flawfinder exectable should be configurable): Execute(The flawfinder exectable should be configurable):
let b:ale_cpp_flawfinder_executable = 'foo/bar' let b:ale_cpp_flawfinder_executable = 'foo/bar'
AssertEqual AssertLinter 'foo/bar', ale#Escape('foo/bar') . ' -CDQS --minlevel=1 %t'
\ ale#Escape('foo/bar')
\ . ' -CDQS --minlevel=1 %t',
\ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))

View File

@ -1,39 +1,16 @@
Before: Before:
Save g:ale_cpp_gcc_executable call ale#assert#SetUpLinterTest('cpp', 'gcc')
Save g:ale_cpp_gcc_options
unlet! g:ale_cpp_gcc_executable
unlet! b:ale_cpp_gcc_executable
unlet! g:ale_cpp_gcc_options
unlet! b:ale_cpp_gcc_options
runtime ale_linters/cpp/gcc.vim
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote' let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd()) \ . ' ' . ale#Escape(getcwd())
\ . ' -std=c++14 -Wall -' \ . ' -std=c++14 -Wall -'
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_cpp_gcc_executable call ale#assert#TearDownLinterTest()
unlet! b:ale_cpp_gcc_options
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'gcc', ale_linters#cpp#gcc#GetExecutable(bufnr('')) AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
let b:ale_cpp_gcc_executable = 'foobar' let b:ale_cpp_gcc_executable = 'foobar'
AssertEqual 'foobar', ale_linters#cpp#gcc#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('gcc') . b:command_tail,
\ ale_linters#cpp#gcc#GetCommand(bufnr(''), [])
let b:ale_cpp_gcc_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#cpp#gcc#GetCommand(bufnr(''), [])

View File

@ -1,42 +1,17 @@
Before: Before:
Save g:ale_cpp_cpplint_executable call ale#assert#SetUpLinterTest('cpp', 'cpplint')
Save g:ale_cpp_cpplint_options
unlet! g:ale_cpp_cpplint_executable
unlet! b:ale_cpp_cpplint_executable
unlet! g:ale_cpp_cpplint_options
unlet! b:ale_cpp_cpplint_options
runtime ale_linters/cpp/cpplint.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:command_tail
unlet! b:ale_cpp_cpplint_executable
unlet! b:ale_cpp_cpplint_options
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'cpplint', ale_linters#cpp#cpplint#GetExecutable(bufnr('')) AssertLinter 'cpplint', ale#Escape('cpplint') . ' %s'
let b:ale_cpp_cpplint_executable = 'foobar' let b:ale_cpp_cpplint_executable = 'foobar'
AssertEqual 'foobar', ale_linters#cpp#cpplint#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('cpplint') . ' %s',
\ ale_linters#cpp#cpplint#GetCommand(bufnr(''))
let b:ale_cpp_cpplint_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . ' %s',
\ ale_linters#cpp#cpplint#GetCommand(bufnr(''))
\
Execute(The options should be configurable): Execute(The options should be configurable):
let b:ale_cpp_cpplint_options = '--something' let b:ale_cpp_cpplint_options = '--something'
AssertEqual AssertLinter 'cpplint', ale#Escape('cpplint') . ' --something %s'
\ ale#Escape('cpplint') . ' --something %s',
\ ale_linters#cpp#cpplint#GetCommand(bufnr(''))

View File

@ -1,34 +1,13 @@
Before: Before:
Save g:ale_cs_mcs_options call ale#assert#SetUpLinterTest('cs', 'mcs')
unlet! g:ale_cs_mcs_options
runtime ale_linters/cs/mcs.vim
let b:command_tail = ' -unsafe --parse'
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:command_tail
unlet! b:ale_cs_mcs_options
call ale#linter#Reset()
Execute(Check for proper default command): Execute(The default command should be correct):
AssertLinter 'mcs', 'mcs -unsafe --parse %t'
let b:command = ale_linters#cs#mcs#GetCommand(bufnr(''))
let b:command = substitute(b:command,'\s\+',' ','g')
AssertEqual
\ b:command,
\ 'mcs -unsafe --parse %t'
Execute(The options should be be used in the command): Execute(The options should be be used in the command):
let b:ale_cs_mcs_options = '-pkg:dotnet' let b:ale_cs_mcs_options = '-pkg:dotnet'
let b:command = ale_linters#cs#mcs#GetCommand(bufnr(''))
let b:command = substitute(b:command,'\s\+',' ','g')
AssertEqual
\ b:command,
\ 'mcs' . b:command_tail . ' ' . b:ale_cs_mcs_options . ' %t',
AssertLinter 'mcs', 'mcs -unsafe --parse -pkg:dotnet %t'

View File

@ -1,93 +1,47 @@
Before: Before:
Save g:ale_cs_mcsc_options call ale#assert#SetUpLinterTest('cs', 'mcsc')
Save g:ale_cs_mcsc_source
Save g:ale_cs_mcsc_assembly_path
Save g:ale_cs_mcsc_assemblies
Save g:ale_buffer_info
let g:ale_buffer_info = {bufnr(''): {'temporary_file_list': []}}
unlet! g:ale_cs_mcsc_options
unlet! g:ale_cs_mcsc_source
unlet! g:ale_cs_mcsc_assembly_path
unlet! g:ale_cs_mcsc_assemblies
let g:prefix = ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
function! GetCommand()
let l:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
let l:command = join(split(l:command))
return substitute(l:command, ':[^ ]\+ -t:module', ':TEMP -t:module', '')
endfunction
runtime ale_linters/cs/mcsc.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:ale_cs_mcsc_options
unlet! g:ale_cs_mcsc_source
unlet! g:ale_cs_mcsc_assembly_path
unlet! g:ale_cs_mcsc_assemblies
unlet! g:ale_prefix
delfunction GetCommand
call ale#linter#Reset()
Execute(The mcsc linter should return the correct default command): Execute(The mcsc linter should return the correct default command):
AssertEqual AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
\ ale#path#BufferCdString(bufnr('')) \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
\ . 'mcs -unsafe' . g:prefix,
\ GetCommand()
Execute(The options should be be used in the command): Execute(The options should be be used in the command):
let g:ale_cs_mcsc_options = '-pkg:dotnet' let g:ale_cs_mcsc_options = '-pkg:dotnet'
AssertEqual AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
\ ale#path#BufferCdString(bufnr('')) \ . 'mcs -unsafe -pkg:dotnet -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
\ . 'mcs -unsafe -pkg:dotnet' . g:prefix,
\ GetCommand()
Execute(The souce path should be be used in the command): Execute(The souce path should be be used in the command):
let g:ale_cs_mcsc_source = '../foo/bar' let g:ale_cs_mcsc_source = '../foo/bar'
AssertEqual AssertLinter 'mcs', 'cd ' . ale#Escape('../foo/bar') . ' && '
\ 'cd ' . ale#Escape('../foo/bar') . ' && ' \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
\ . 'mcs -unsafe' . g:prefix,
\ GetCommand()
Execute(The list of search pathes for assemblies should be be used in the command if not empty): Execute(The list of search pathes for assemblies should be be used in the command if not empty):
let g:ale_cs_mcsc_assembly_path = ['/usr/lib/mono', '../foo/bar'] let g:ale_cs_mcsc_assembly_path = ['/usr/lib/mono', '../foo/bar']
AssertEqual AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
\ ale#path#BufferCdString(bufnr('')) \ . 'mcs -unsafe'
\ . 'mcs -unsafe' \ . ' -lib:' . ale#Escape('/usr/lib/mono') . ',' . ale#Escape('../foo/bar')
\ . ' -lib:' . ale#Escape('/usr/lib/mono') . ',' . ale#Escape('../foo/bar') \ . ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
\ . g:prefix,
\ GetCommand()
let g:ale_cs_mcsc_assembly_path = [] let g:ale_cs_mcsc_assembly_path = []
AssertEqual AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
\ ale#path#BufferCdString(bufnr('')) \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
\ . 'mcs -unsafe' . g:prefix,
\ GetCommand()
Execute(The list of assemblies should be be used in the command if not empty): Execute(The list of assemblies should be be used in the command if not empty):
let g:ale_cs_mcsc_assemblies = ['foo.dll', 'bar.dll'] let g:ale_cs_mcsc_assemblies = ['foo.dll', 'bar.dll']
AssertEqual AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
\ ale#path#BufferCdString(bufnr('')) \ . 'mcs -unsafe'
\ . 'mcs -unsafe' \ . ' -r:' . ale#Escape('foo.dll') . ',' . ale#Escape('bar.dll')
\ . ' -r:' . ale#Escape('foo.dll') . ',' . ale#Escape('bar.dll') \ . ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
\ . g:prefix,
\ GetCommand()
let g:ale_cs_mcsc_assemblies = [] let g:ale_cs_mcsc_assemblies = []
AssertEqual AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
\ ale#path#BufferCdString(bufnr('')) \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
\ . 'mcs -unsafe' . g:prefix,
\ GetCommand()

View File

@ -1,25 +1,18 @@
Before: Before:
runtime ale_linters/ruby/rubocop.vim call ale#assert#SetUpLinterTest('cucumber', 'cucumber')
call ale#test#SetDirectory('/testplugin/test/')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
call ale#test#RestoreDirectory()
Execute(Should require the nearest features dir, if one is found): Execute(Should require the nearest features dir, if one is found):
call ale#test#SetFilename('cucumber_fixtures/features/cuke.feature') call ale#test#SetFilename('../cucumber_fixtures/features/cuke.feature')
AssertEqual AssertLinter 'cucumber',
\ 'cucumber --dry-run --quiet --strict --format=json ' \ 'cucumber --dry-run --quiet --strict --format=json '
\ . '-r ' . ale#Escape(ale#path#Simplify(g:dir . '/cucumber_fixtures/features/')) . ' %t', \ . '-r ' . ale#Escape(ale#path#Simplify(g:dir . '/../cucumber_fixtures/features/')) . ' %t'
\ ale_linters#cucumber#cucumber#GetCommand(bufnr(''))
Execute(Should require nothing if no features dir is found): Execute(Should require nothing if no features dir is found):
call ale#test#SetFilename('something/without/a/features/dir') call ale#test#SetFilename('something/without/a/features/dir')
AssertEqual AssertLinter 'cucumber',
\ 'cucumber --dry-run --quiet --strict --format=json ' \ 'cucumber --dry-run --quiet --strict --format=json %t'
\ . ' %t',
\ ale_linters#cucumber#cucumber#GetCommand(bufnr(''))

View File

@ -1,36 +1,14 @@
Before: Before:
Save g:ale_cuda_nvcc_executable call ale#assert#SetUpLinterTest('cuda', 'nvcc')
Save g:ale_cuda_nvcc_options
unlet! g:ale_cuda_nvcc_executable
unlet! b:ale_cuda_nvcc_executable
unlet! g:ale_cuda_nvcc_options
unlet! b:ale_cuda_nvcc_options
runtime ale_linters/cuda/nvcc.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:ale_cuda_nvcc_executable
unlet! b:ale_cuda_nvcc_options
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'nvcc', ale_linters#cuda#nvcc#GetExecutable(bufnr('')) AssertLinter 'nvcc',
\ ale#Escape('nvcc') . ' -cuda -std=c++11 %s -o ' . g:ale#util#nul_file
let b:ale_cuda_nvcc_executable = 'foobar' let b:ale_cuda_nvcc_executable = 'foobar'
AssertEqual 'foobar', ale_linters#cuda#nvcc#GetExecutable(bufnr('')) AssertLinter 'foobar',
\ ale#Escape('foobar') . ' -cuda -std=c++11 %s -o ' . g:ale#util#nul_file
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('nvcc') . ' -cuda -std=c++11 %s'
\ . ' -o ' . g:ale#util#nul_file,
\ ale_linters#cuda#nvcc#GetCommand(bufnr(''))
let b:ale_cuda_nvcc_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . ' -cuda -std=c++11 %s'
\ . ' -o ' . g:ale#util#nul_file,
\ ale_linters#cuda#nvcc#GetCommand(bufnr(''))

View File

@ -1,40 +1,20 @@
Before: Before:
Save g:ale_dart_dartanalyzer_executable call ale#assert#SetUpLinterTest('dart', 'dartanalyzer')
unlet! g:ale_dart_dartanalyzer_executable
runtime ale_linters/dart/dartanalyzer.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The default command and executable should be correct): Execute(The default command and executable should be correct):
AssertEqual AssertLinter 'dartanalyzer', ale#Escape('dartanalyzer') . ' %s'
\ 'dartanalyzer',
\ ale_linters#dart#dartanalyzer#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('dartanalyzer') . ' %s',
\ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
Execute(The executable should be configurable): Execute(The executable should be configurable):
let g:ale_dart_dartanalyzer_executable = '/usr/lib/dart/bin/dartanalyzer' let g:ale_dart_dartanalyzer_executable = 'foobar'
AssertEqual AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
\ '/usr/lib/dart/bin/dartanalyzer',
\ ale_linters#dart#dartanalyzer#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('/usr/lib/dart/bin/dartanalyzer') . ' %s',
\ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
Execute(The .packages file should be set if detected): Execute(The .packages file should be set if detected):
call ale#test#SetFilename('dart_paths/foo') call ale#test#SetFilename('dart_paths/foo')
AssertEqual AssertLinter 'dartanalyzer', ale#Escape('dartanalyzer')
\ ale#Escape('dartanalyzer')
\ . ' --packages ' . ale#Escape(ale#path#Simplify(g:dir . '/dart_paths/.packages')) \ . ' --packages ' . ale#Escape(ale#path#Simplify(g:dir . '/dart_paths/.packages'))
\ . ' %s', \ . ' %s'
\ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))

View File

@ -1,37 +1,19 @@
Before: Before:
runtime ale_linters/elixir/mix.vim call ale#assert#SetUpLinterTest('elixir', 'mix')
call ale#test#SetDirectory('/testplugin/test/command_callback')
let g:project_root = ale#path#Simplify(g:dir . '/mix_paths/wrapped_project')
let g:env_prefix = has('win32') let g:env_prefix = has('win32')
\ ? 'set MIX_BUILD_PATH=TEMP && ' \ ? 'set MIX_BUILD_PATH=' . ale#Escape('TEMP_DIR') . ' && '
\ : 'MIX_BUILD_PATH=TEMP ' \ : 'MIX_BUILD_PATH=' . ale#Escape('TEMP_DIR') . ' '
function! GetCommand(buffer) abort
let l:command = ale_linters#elixir#mix#GetCommand(a:buffer)
return substitute(l:command, 'MIX_BUILD_PATH=[^ ]\+', 'MIX_BUILD_PATH=TEMP', '')
endfunction
After: After:
Restore
unlet! g:env_prefix unlet! g:env_prefix
unlet! g:project_root
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
delfunction GetCommand
Execute(The default mix command should be correct): Execute(The default mix command should be correct):
call ale#test#SetFilename('mix_paths/wrapped_project/lib/app.ex') call ale#test#SetFilename('mix_paths/wrapped_project/lib/app.ex')
AssertEqual AssertLinter 'mix',
\ GetCommand(bufnr('')), \ ale#path#CdString(ale#path#Simplify(g:dir . '/mix_paths/wrapped_project'))
\ ale#path#CdString(g:project_root)
\ . g:env_prefix \ . g:env_prefix
\ . 'mix compile %s' \ . 'mix compile %s'

View File

@ -1,21 +1,16 @@
Before: Before:
runtime ale_linters/eruby/erb.vim call ale#assert#SetUpLinterTest('eruby', 'erb')
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
Execute(Executable should not contain any filter code by default): Execute(Executable should not contain any filter code by default):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb') call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb')
AssertEqual AssertLinter 'erb', 'erb -P -T - -x %t | ruby -c'
\ 'erb -P -T - -x %t | ruby -c',
\ ale_linters#eruby#erb#GetCommand(bufnr(''))
Execute(Executable should filter invalid eRuby when inside a Rails project): Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
AssertEqual AssertLinter 'erb',
\ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c', \ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
\ ale_linters#eruby#erb#GetCommand(bufnr(''))

View File

@ -1,66 +1,45 @@
Before: Before:
Save g:ale_erlang_syntaxerl_executable call ale#assert#SetUpLinterTest('erlang', 'syntaxerl')
unlet! g:ale_erlang_syntaxerl_executable
unlet! b:ale_erlang_syntaxerl_executable
runtime ale_linters/erlang/syntaxerl.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset() Execute (The default commands should be correct):
AssertLinter 'syntaxerl', [
\ ale#Escape('syntaxerl') . ' -h',
\ ale#Escape('syntaxerl') . ' %t',
\]
Execute (The executable should be correct): Execute (The executable should be configurable):
AssertEqual 'syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr('')) let b:ale_erlang_syntaxerl_executable = 'foobar'
let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl' AssertLinter 'foobar', [
AssertEqual '/some/other/syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr('')) \ ale#Escape('foobar') . ' -h',
\ ale#Escape('foobar') . ' %t',
let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl' \]
AssertEqual '/yet/another/syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr(''))
Execute (The executable should be presented in the feature check command):
let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
AssertEqual
\ ale#Escape('/some/other/syntaxerl') . ' -h',
\ ale_linters#erlang#syntaxerl#FeatureCheck(bufnr(''))
let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
AssertEqual
\ ale#Escape('/yet/another/syntaxerl') . ' -h',
\ ale_linters#erlang#syntaxerl#FeatureCheck(bufnr(''))
Execute (The executable should be presented in the command):
let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
AssertEqual
\ ale#Escape('/some/other/syntaxerl') . ' %t',
\ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
AssertEqual
\ ale#Escape('/yet/another/syntaxerl') . ' %t',
\ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
Execute (The -b option should be used when available): Execute (The -b option should be used when available):
AssertEqual ale#Escape('syntaxerl') . ' %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [ WithChainResults [
\ 'Syntax checker for Erlang (0.14.0)', \ 'Syntax checker for Erlang (0.14.0)',
\ 'Usage: syntaxerl [-d | --debug] <FILENAME>', \ 'Usage: syntaxerl [-d | --debug] <FILENAME>',
\ ' syntaxerl <-h | --help>', \ ' syntaxerl <-h | --help>',
\ ' -d, --debug Enable debug output', \ ' -d, --debug Enable debug output',
\ ' -h, --help Show this message', \ ' -h, --help Show this message',
\ ]) \]
AssertLinter 'syntaxerl', [
\ ale#Escape('syntaxerl') . ' -h',
\ ale#Escape('syntaxerl') . ' %t',
\]
AssertEqual ale#Escape('syntaxerl') . ' -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [ WithChainResults [
\ 'Syntax checker for Erlang (0.14.0)', \ 'Syntax checker for Erlang (0.14.0)',
\ 'Usage: syntaxerl [-b | --base <FILENAME>] [-d | --debug] <FILENAME>', \ 'Usage: syntaxerl [-b | --base <FILENAME>] [-d | --debug] <FILENAME>',
\ ' syntaxerl <-h | --help>', \ ' syntaxerl <-h | --help>',
\ ' -b, --base Set original filename', \ ' -b, --base Set original filename',
\ ' -d, --debug Enable debug output', \ ' -d, --debug Enable debug output',
\ ' -h, --help Show this message', \ ' -h, --help Show this message',
\ ]) \]
AssertLinter 'syntaxerl', [
\ ale#Escape('syntaxerl') . ' -h',
\ ale#Escape('syntaxerl') . ' -b %s %t',
\]

View File

@ -1,31 +1,32 @@
Before: Before:
runtime ale_linters/eruby/erubi.vim call ale#assert#SetUpLinterTest('eruby', 'erubi')
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
Execute(Executable should not contain any filter code by default): Execute(Executable should not contain any filter code by default):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb') call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb')
AssertEqual AssertLinter 'ruby', [
\ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
\ 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c', \ 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c',
\ ale_linters#eruby#erubi#GetCommand(bufnr(''), []) \]
Execute(Executable should filter invalid eRuby when inside a Rails project): Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
AssertEqual AssertLinter 'ruby', [
\ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
\ 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c', \ 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c',
\ ale_linters#eruby#erubi#GetCommand(bufnr(''), [])
Execute(Command should be blank if the first command in the chain return output):
let output_lines = [
\ "/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- erubi/capture_end (LoadError)",
\ " from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'",
\] \]
AssertEqual Execute(Command should be blank if the first command in the chain returns output):
WithChainResults [
\ "/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- erubi/capture_end (LoadError)",
\ " from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'",
\]
AssertLinter 'ruby', [
\ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
\ '', \ '',
\ ale_linters#eruby#erubi#GetCommand(bufnr(''), output_lines) \]

View File

@ -1,21 +1,16 @@
Before: Before:
runtime ale_linters/eruby/erubis.vim call ale#assert#SetUpLinterTest('eruby', 'erubis')
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
Execute(Executable should not contain any filter code by default): Execute(Executable should not contain any filter code by default):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb') call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb')
AssertEqual AssertLinter 'erubis', 'erubis -x %t | ruby -c'
\ 'erubis -x %t | ruby -c',
\ ale_linters#eruby#erubis#GetCommand(bufnr(''))
Execute(Executable should filter invalid eRuby when inside a Rails project): Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
AssertEqual AssertLinter 'erubis',
\ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c', \ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
\ ale_linters#eruby#erubis#GetCommand(bufnr(''))

View File

@ -1,91 +1,75 @@
Before: Before:
Save g:ale_python_flake8_executable call ale#assert#SetUpLinterTest('python', 'flake8')
Save g:ale_python_flake8_options
Save g:ale_python_flake8_use_global
Save g:ale_python_flake8_change_directory
unlet! g:ale_python_flake8_executable
unlet! g:ale_python_flake8_args
unlet! g:ale_python_flake8_options
unlet! g:ale_python_flake8_use_global
unlet! g:ale_python_flake8_change_directory
let b:bin_dir = has('win32') ? 'Scripts' : 'bin' let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
runtime ale_linters/python/flake8.vim WithChainResults ['3.0.0']
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore
unlet! g:ale_python_flake8_args
unlet! b:bin_dir
unlet! b:executable unlet! b:executable
unlet! b:bin_dir
call ale#test#RestoreDirectory() call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
call ale#semver#ResetVersionCache()
Execute(The flake8 callbacks should return the correct default values): Execute(The flake8 callbacks should return the correct default values):
AssertEqual AssertLinter 'flake8', [
\ 'flake8',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('flake8') . ' --version', \ ale#Escape('flake8') . ' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -', \ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0']) \]
" The version check should be cached.
WithChainResults []
AssertLinter 'flake8', [
\ '',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
" Try with older versions. " Try with older versions.
call ale#semver#ResetVersionCache() call ale#semver#ResetVersionCache()
AssertEqual WithChainResults ['2.9.9']
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default -', \ . ale#Escape('flake8') . ' --format=default -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) \]
Execute(The option for disabling changing directories should work): Execute(The option for disabling changing directories should work):
let g:ale_python_flake8_change_directory = 0 let g:ale_python_flake8_change_directory = 0
AssertEqual AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -', \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0']) \]
Execute(The flake8 command callback should let you set options): Execute(The flake8 command callback should let you set options):
let g:ale_python_flake8_options = '--some-option' let g:ale_python_flake8_options = '--some-option'
AssertEqual WithChainResults ['3.0.4']
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') \ . ale#Escape('flake8') . ' --some-option'
\ . ' --some-option --format=default' \ . ' --format=default --stdin-display-name %s -',
\ . ' --stdin-display-name %s -', \]
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.4'])
call ale#semver#ResetVersionCache() call ale#semver#ResetVersionCache()
WithChainResults ['2.9.9']
AssertEqual AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') \ . ale#Escape('flake8') . ' --some-option --format=default -',
\ . ' --some-option --format=default -', \]
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
Execute(You should be able to set a custom executable and it should be escaped): Execute(You should be able to set a custom executable and it should be escaped):
let g:ale_python_flake8_executable = 'executable with spaces' let g:ale_python_flake8_executable = 'executable with spaces'
AssertEqual AssertLinter 'executable with spaces', [
\ 'executable with spaces',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('executable with spaces') . ' --version', \ ale#Escape('executable with spaces') . ' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('executable with spaces') \ . ale#Escape('executable with spaces')
\ . ' --format=default' \ . ' --format=default'
\ . ' --stdin-display-name %s -', \ . ' --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0']) \]
Execute(The flake8 callbacks should detect virtualenv directories): Execute(The flake8 callbacks should detect virtualenv directories):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
@ -94,17 +78,13 @@ Execute(The flake8 callbacks should detect virtualenv directories):
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/flake8' \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/flake8'
\) \)
AssertEqual AssertLinter b:executable, [
\ b:executable,
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape(b:executable) . ' --version', \ ale#Escape(b:executable) . ' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape(b:executable) \ . ale#Escape(b:executable)
\ . ' --format=default --stdin-display-name %s -', \ . ' --format=default'
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0']) \ . ' --stdin-display-name %s -',
\]
Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in): Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_manifest/namespace/foo/bar.py') silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_manifest/namespace/foo/bar.py')
@ -148,37 +128,32 @@ Execute(Using `python -m flake8` should be supported for running flake8):
let g:ale_python_flake8_executable = 'python' let g:ale_python_flake8_executable = 'python'
let g:ale_python_flake8_options = '-m flake8 --some-option' let g:ale_python_flake8_options = '-m flake8 --some-option'
AssertEqual WithChainResults ['2.9.9']
\ 'python', AssertLinter 'python', [
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('python') . ' -m flake8 --version', \ ale#Escape('python') . ' -m flake8 --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('python') . ' -m flake8 --some-option --format=default -', \ . ale#Escape('python')
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) \ . ' -m flake8 --some-option --format=default -'
\]
call ale#semver#ResetVersionCache() call ale#semver#ResetVersionCache()
" Leading spaces shouldn't matter " Leading spaces shouldn't matter
let g:ale_python_flake8_options = ' -m flake8 --some-option' let g:ale_python_flake8_options = ' -m flake8 --some-option'
AssertEqual WithChainResults ['2.9.9']
\ 'python', AssertLinter 'python', [
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('python') . ' -m flake8 --version', \ ale#Escape('python') . ' -m flake8 --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('python') . ' -m flake8 --some-option --format=default -', \ . ale#Escape('python')
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) \ . ' -m flake8 --some-option --format=default -'
\]
Execute(Setting executable to 'pipenv' appends 'run flake8'): Execute(Setting executable to 'pipenv' should append 'run flake8'):
let g:ale_python_flake8_executable = 'path/to/pipenv' let g:ale_python_flake8_executable = 'path/to/pipenv'
AssertEqual " FIXME: pipenv should check the vresion with flake8.
WithChainResults []
AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run flake8 --format=default --stdin-display-name %s -', \ . ale#Escape('path/to/pipenv') . ' run flake8 --format=default -'
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])

View File

@ -1,44 +1,18 @@
Before: Before:
Save g:ale_chef_foodcritic_executable call ale#assert#SetUpLinterTest('chef', 'foodcritic')
Save g:ale_chef_foodcritic_options
unlet! g:ale_chef_foodcritic_executable
unlet! g:ale_chef_foodcritic_options
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/chef/foodcritic.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:ale_chef_foodcritic_executable
unlet! b:ale_chef_foodcritic_options
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual AssertLinter 'foodcritic', ale#Escape('foodcritic') . ' %s'
\ 'foodcritic',
\ ale_linters#chef#foodcritic#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('foodcritic') . ' %s',
\ ale_linters#chef#foodcritic#GetCommand(bufnr(''))
Execute(Extra options should be included with escapeed tildes (~)): Execute(Extra options should be included with escapeed tildes (~)):
let b:ale_chef_foodcritic_options = '-t ~F011' let b:ale_chef_foodcritic_options = '-t ~F011'
AssertEqual AssertLinter 'foodcritic', ale#Escape('foodcritic') . ' -t \~F011 %s'
\ ale#Escape('foodcritic') . ' -t \~F011 %s',
\ ale_linters#chef#foodcritic#GetCommand(bufnr(''))
Execute(The executable should be configurable): Execute(The executable should be configurable):
let b:ale_chef_foodcritic_executable = 'foobar' let b:ale_chef_foodcritic_executable = 'foobar'
AssertEqual AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
\ 'foobar',
\ ale_linters#chef#foodcritic#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('foobar') . ' %s',
\ ale_linters#chef#foodcritic#GetCommand(bufnr(''))

View File

@ -1,17 +1,13 @@
Before: Before:
runtime ale_linters/scala/fsc.vim call ale#assert#SetUpLinterTest('scala', 'fsc')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
Given scala(An empty Scala file): Given scala(An empty Scala file):
Execute(The default executable and command should be correct): Execute(The default executable and command should be correct):
AssertEqual 'fsc', ale_linters#scala#fsc#GetExecutable(bufnr('')) AssertLinter 'fsc', ale#Escape('fsc') . ' -Ystop-after:parser %t'
AssertEqual
\ ale#Escape('fsc') . ' -Ystop-after:parser %t',
\ ale_linters#scala#fsc#GetCommand(bufnr(''))
Given scala.sbt(An empty SBT file): Given scala.sbt(An empty SBT file):
Execute(fsc should not be run for sbt files): Execute(fsc should not be run for sbt files):
AssertEqual '', ale_linters#scala#fsc#GetExecutable(bufnr('')) AssertLinter '', ''
AssertEqual '', ale_linters#scala#fsc#GetCommand(bufnr(''))

View File

@ -1,34 +1,19 @@
Before: Before:
Save g:ale_fuse_fusionlint_options call ale#assert#SetUpLinterTest('fuse', 'fusionlint')
Save g:ale_fuse_fusionlint_executable
unlet! g:ale_fuse_fusionlint_options
unlet! g:ale_fuse_fusionlint_executable
runtime ale_linters/fuse/fusionlint.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The fuse fusionlint command callback should return the correct default string): Execute(The fuse fusionlint command callback should return the correct default string):
AssertEqual ale#Escape('fusion-lint') . ' --filename %s -i', AssertLinter 'fusion-lint', ale#Escape('fusion-lint') . ' --filename %s -i'
\ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))
Execute(The fuse fusionlint command callback should let you set options): Execute(The fuse fusionlint command callback should let you set options):
let g:ale_fuse_fusionlint_options = '--example-option argument' let g:ale_fuse_fusionlint_options = '--example-option argument'
AssertEqual AssertLinter 'fusion-lint',
\ ale#Escape('fusion-lint') \ ale#Escape('fusion-lint') . ' --example-option argument --filename %s -i'
\ . ' --example-option argument --filename %s -i',
\ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))
Execute(The fusionlint executable should be configurable): Execute(The fusionlint executable should be configurable):
let g:ale_fuse_fusionlint_executable = 'util/linter.fuse' let g:ale_fuse_fusionlint_executable = 'foobar'
AssertEqual 'util/linter.fuse', ale_linters#fuse#fusionlint#GetExecutable(1) AssertLinter 'foobar', ale#Escape('foobar') . ' --filename %s -i'
AssertEqual
\ ale#Escape('util/linter.fuse')
\ . ' --filename %s -i',
\ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))

View File

@ -1,40 +1,25 @@
Before: Before:
Save g:ale_awk_gawk_executable call ale#assert#SetUpLinterTest('awk', 'gawk')
Save g:ale_awk_gawk_options
unlet! g:ale_awk_gawk_executable
unlet! g:ale_awk_gawk_options
runtime ale_linters/awk/gawk.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:command_tail
unlet! b:ale_awk_gawk_executable
unlet! b:ale_awk_gawk_options
call ale#linter#Reset() Execute(The default command should be correct):
AssertLinter 'gawk',
Execute(The executable should be used in the command): \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
AssertEqual \ . ' -f %t --lint /dev/null'
\ 'gawk'
\ . " --source 'BEGIN { exit } END { exit 1 }'"
\ . ' ' . '-f %t --lint /dev/null',
\ ale_linters#awk#gawk#GetCommand(bufnr(''))
Execute(The executable should be configurable):
let b:ale_awk_gawk_executable = '/other/gawk' let b:ale_awk_gawk_executable = '/other/gawk'
AssertEqual AssertLinter '/other/gawk',
\ '/other/gawk' \ ale#Escape('/other/gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
\ . " --source 'BEGIN { exit } END { exit 1 }'" \ . ' -f %t --lint /dev/null'
\ . ' ' . '-f %t --lint /dev/null',
\ ale_linters#awk#gawk#GetCommand(bufnr(''))
Execute(The options should be configurable):
let b:ale_awk_gawk_executable = 'gawk' let b:ale_awk_gawk_executable = 'gawk'
let b:ale_awk_gawk_options = '--something' let b:ale_awk_gawk_options = '--something'
AssertEqual AssertLinter 'gawk',
\ 'gawk' \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
\ . " --source 'BEGIN { exit } END { exit 1 }'" \ . ' --something -f %t --lint /dev/null'
\ . ' --something'
\ . ' ' . '-f %t --lint /dev/null',
\ ale_linters#awk#gawk#GetCommand(bufnr(''))

View File

@ -1,31 +1,24 @@
Before: Before:
runtime ale_linters/fortran/gcc.vim call ale#assert#SetUpLinterTest('fortran', 'gcc')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
let g:ale_fortran_gcc_options = '-Wall'
let g:ale_fortran_gcc_use_free_form = 1
let g:ale_fortran_gcc_executable = 'gcc'
Execute(The fortran gcc command callback should return the correct default string): Execute(The fortran gcc command callback should return the correct default string):
AssertEqual 'gcc -S -x f95 -fsyntax-only -ffree-form -Wall -', AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wall -'
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))
Execute(The fortran gcc command callback should let you set options): Execute(The fortran gcc command callback should let you set options):
let g:ale_fortran_gcc_options = '-Wotherthings' let g:ale_fortran_gcc_options = '-Wotherthings'
AssertEqual 'gcc -S -x f95 -fsyntax-only -ffree-form -Wotherthings -', AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wotherthings -'
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))
Execute(The fortran gcc command callback should let you use -ffixed-form): Execute(The fortran gcc command callback should let you use -ffixed-form):
let g:ale_fortran_gcc_use_free_form = 0 let g:ale_fortran_gcc_use_free_form = 0
AssertEqual 'gcc -S -x f95 -fsyntax-only -ffixed-form -Wall -', AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffixed-form -Wall -'
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))
Execute(The fortran executable should be configurable): Execute(The fortran executable should be configurable):
let g:ale_fortran_gcc_executable = 'gfortran' let g:ale_fortran_gcc_executable = 'gfortran'
AssertEqual 'gfortran', ale_linters#fortran#gcc#GetExecutable(1) AssertLinter 'gfortran',
AssertEqual 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -', \ 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -'
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))

View File

@ -1,84 +1,43 @@
Before: Before:
Save g:ale_gitcommit_gitlint_executable call ale#assert#SetUpLinterTest('gitcommit', 'gitlint')
Save g:ale_gitcommit_gitlint_options
Save g:ale_gitcommit_gitlint_use_global
unlet! g:ale_gitcommit_gitlint_executable
unlet! g:ale_gitcommit_gitlint_options
unlet! g:ale_gitcommit_gitlint_use_global
runtime ale_linters/gitcommit/gitlint.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin' let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
let b:command_tail = ' lint'
After: After:
Restore
call ale#test#RestoreDirectory()
call ale#linter#Reset()
unlet! b:bin_dir unlet! b:bin_dir
unlet! b:executable unlet! b:executable
call ale#assert#TearDownLinterTest()
Execute(The gitlint callbacks should return the correct default values): Execute(The gitlint callbacks should return the correct default values):
AssertEqual AssertLinter 'gitlint', ale#Escape('gitlint') . ' lint'
\ 'gitlint',
\ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('gitlint') . b:command_tail,
\ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
Execute(The gitlint executable should be configurable, and escaped properly): Execute(The gitlint executable should be configurable, and escaped properly):
let g:ale_gitcommit_gitlint_executable = 'executable with spaces' let g:ale_gitcommit_gitlint_executable = 'executable with spaces'
AssertEqual AssertLinter 'executable with spaces',
\ 'executable with spaces', \ ale#Escape('executable with spaces') . ' lint'
\ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('executable with spaces') . b:command_tail,
\ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
Execute(The gitlint command callback should let you set options): Execute(The gitlint command callback should let you set options):
let g:ale_gitcommit_gitlint_options = '--some-option' let g:ale_gitcommit_gitlint_options = '--some-option'
AssertEqual AssertLinter 'gitlint', ale#Escape('gitlint') . ' --some-option lint'
\ ale#Escape('gitlint') . ' --some-option' . b:command_tail,
\ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
Execute(The gitlint callbacks shouldn't detect virtualenv directories where they don't exist): Execute(The gitlint callbacks shouldn't detect virtualenv directories where they don't exist):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/COMMIT_EDITMSG') call ale#test#SetFilename('python_paths/no_virtualenv/subdir/foo/COMMIT_EDITMSG')
AssertEqual AssertLinter 'gitlint', ale#Escape('gitlint') . ' lint'
\ 'gitlint',
\ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('gitlint') . b:command_tail,
\ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
Execute(The gitlint callbacks should detect virtualenv directories): Execute(The gitlint callbacks should detect virtualenv directories):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG') call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG')
let b:executable = ale#path#Simplify( let b:executable = ale#path#Simplify(
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/gitlint' \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/gitlint'
\) \)
AssertEqual AssertLinter b:executable, ale#Escape(b:executable) . ' lint'
\ b:executable,
\ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape(b:executable) . b:command_tail,
\ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
Execute(You should able able to use the global gitlint instead): Execute(You should able able to use the global gitlint instead):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG') call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG')
let g:ale_gitcommit_gitlint_use_global = 1 let g:ale_gitcommit_gitlint_use_global = 1
AssertEqual AssertLinter 'gitlint', ale#Escape('gitlint') . ' lint'
\ 'gitlint',
\ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('gitlint') . b:command_tail,
\ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))

View File

@ -1,40 +1,19 @@
Before: Before:
Save g:ale_glsl_glslang_executable call ale#assert#SetUpLinterTest('glsl', 'glslang')
Save g:ale_glsl_glslang_options
unlet! g:ale_glsl_glslang_executable
unlet! g:ale_glsl_glslang_options
runtime ale_linters/glsl/glslang.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(Executable should default to glslangValidator): Execute(The default command should be correct):
AssertEqual AssertLinter 'glslangValidator', ale#Escape('glslangValidator') . ' -C %t'
\ 'glslangValidator',
\ ale_linters#glsl#glslang#GetExecutable(bufnr(''))
Execute(Executable should be configurable): Execute(The executable should be configurable):
let g:ale_glsl_glslang_executable = 'foobar' let b:ale_glsl_glslang_executable = 'foobar'
AssertEqual
\ 'foobar',
\ ale_linters#glsl#glslang#GetExecutable(bufnr(''))
Execute(Command should use executable): AssertLinter 'foobar', ale#Escape('foobar') . ' -C %t'
AssertEqual
\ 'glslangValidator -C %t',
\ ale_linters#glsl#glslang#GetCommand(bufnr(''))
let g:ale_glsl_glslang_executable = 'foobar'
AssertEqual
\ 'foobar -C %t',
\ ale_linters#glsl#glslang#GetCommand(bufnr(''))
Execute(Options should work): Execute(Options should work):
let g:ale_glsl_glslang_options = '--test' let g:ale_glsl_glslang_options = '--test'
AssertEqual
\ 'glslangValidator --test -C %t', AssertLinter 'glslangValidator',
\ ale_linters#glsl#glslang#GetCommand(bufnr('')) \ ale#Escape('glslangValidator') . ' --test -C %t'

View File

@ -1,37 +1,19 @@
Before: Before:
Save g:ale_glsl_glslls_executable call ale#assert#SetUpLinterTest('glsl', 'glslls')
Save g:ale_glsl_glslls_logfile
unlet! g:ale_glsl_glslls_executable
unlet! g:ale_glsl_glslls_logfile
runtime ale_linters/glsl/glslls.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(Executable should default to 'glslls'): Execute(The default command should be correct):
AssertEqual AssertLinter 'glslls', ale#Escape('glslls') . ' --stdin'
\ 'glslls',
\ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
Execute(Executable should be configurable): Execute(Executable should be configurable):
let g:ale_glsl_glslls_executable = 'foobar' let b:ale_glsl_glslls_executable = 'foobar'
AssertEqual
\ 'foobar',
\ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
Execute(Command should use executable): AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin'
let command1 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
AssertEqual command1, ale#Escape('glslls') . ' --stdin'
let g:ale_glsl_glslls_executable = 'foobar'
let command2 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
AssertEqual command2, ale#Escape('foobar') . ' --stdin'
Execute(Setting logfile should work): Execute(Setting logfile should work):
let g:ale_glsl_glslls_logfile = '/tmp/test.log' let b:ale_glsl_glslls_logfile = '/tmp/test.log'
let command = ale_linters#glsl#glslls#GetCommand(bufnr(''))
AssertEqual command, ale#Escape('glslls') . ' --verbose -l /tmp/test.log --stdin' AssertLinter 'glslls',
\ ale#Escape('glslls') . ' --verbose -l /tmp/test.log --stdin'

View File

@ -1,52 +1,36 @@
Before: Before:
Save g:ale_go_gobuild_options call ale#assert#SetUpLinterTest('go', 'gobuild')
unlet! g:ale_go_gobuild_options
let g:env_prefix = has('win32') let g:env_prefix = has('win32')
\ ? 'set GOPATH=' . ale#Escape('/foo/bar') . ' && ' \ ? 'set GOPATH=' . ale#Escape('/foo/bar') . ' && '
\ : 'GOPATH=' . ale#Escape('/foo/bar') . ' ' \ : 'GOPATH=' . ale#Escape('/foo/bar') . ' '
runtime ale_linters/go/gobuild.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale_linters#go#gobuild#ResetEnv() call ale_linters#go#gobuild#ResetEnv()
WithChainResults ['/foo/bar', '/foo/baz']
After: After:
Restore
unlet! g:env_prefix unlet! g:env_prefix
call ale#assert#TearDownLinterTest()
call ale#linter#Reset() Execute(The default commands should be correct):
call ale#test#RestoreDirectory() AssertLinter 'go', [
\ 'go env GOPATH GOROOT',
Execute(The default gobuild command should be correct):
AssertEqual
\ ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']),
\ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'go test -c -o /dev/null ./' \ . 'go test -c -o /dev/null ./'
\]
Execute(The command for getting GOPATH should be correct):
AssertEqual ale_linters#go#gobuild#GoEnv(bufnr('')), 'go env GOPATH GOROOT'
call ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz'])
" We shouldn't run `go env` many times after we've got it. " We shouldn't run `go env` many times after we've got it.
AssertEqual ale_linters#go#gobuild#GoEnv(bufnr('')), '' AssertLinter 'go', [
\ '',
Execute(The GOPATH output should be used after it has been read once):
call ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz'])
AssertEqual
\ ale_linters#go#gobuild#GetCommand(bufnr(''), []),
\ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'go test -c -o /dev/null ./' \ . 'go test -c -o /dev/null ./'
\]
Execute(Extra options should be supported): Execute(Extra options should be supported):
let g:ale_go_gobuild_options = '--foo-bar' let g:ale_go_gobuild_options = '--foo-bar'
AssertEqual AssertLinter 'go', [
\ ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']), \ 'go env GOPATH GOROOT',
\ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'go test --foo-bar -c -o /dev/null ./' \ . 'go test --foo-bar -c -o /dev/null ./'
\]

View File

@ -1,61 +1,38 @@
Before: Before:
Save b:ale_go_gometalinter_executable call ale#assert#SetUpLinterTest('go', 'gometalinter')
Save b:ale_go_gometalinter_options
Save b:ale_go_gometalinter_lint_package
let b:ale_go_gometalinter_executable = 'gometalinter'
let b:ale_go_gometalinter_options = ''
let b:ale_go_gometalinter_lint_package = 0
runtime ale_linters/go/gometalinter.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('test.go') call ale#test#SetFilename('test.go')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory() Execute(The gometalinter defaults should be correct):
call ale#linter#Reset() AssertLinter 'gometalinter',
Execute(The gometalinter callback should return the right defaults):
AssertEqual
\ 'gometalinter',
\ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('gometalinter') \ . ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .', \ . ' .'
\ ale_linters#go#gometalinter#GetCommand(bufnr(''))
Execute(The gometalinter callback should use a configured executable): Execute(The gometalinter callback should use a configured executable):
let b:ale_go_gometalinter_executable = 'something else' let b:ale_go_gometalinter_executable = 'something else'
AssertEqual AssertLinter 'something else',
\ 'something else',
\ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('something else') \ . ale#Escape('something else')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .', \ . ' .'
\ ale_linters#go#gometalinter#GetCommand(bufnr(''))
Execute(The gometalinter callback should use configured options): Execute(The gometalinter callback should use configured options):
let b:ale_go_gometalinter_options = '--foobar' let b:ale_go_gometalinter_options = '--foobar'
AssertEqual AssertLinter 'gometalinter',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('gometalinter') \ . ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' --foobar' . ' .', \ . ' --foobar' . ' .'
\ ale_linters#go#gometalinter#GetCommand(bufnr(''))
Execute(The gometalinter `lint_package` option should use the correct command): Execute(The gometalinter `lint_package` option should use the correct command):
let b:ale_go_gometalinter_lint_package = 1 let b:ale_go_gometalinter_lint_package = 1
AssertEqual AssertLinter 'gometalinter',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('gometalinter') . ' .', \ . ale#Escape('gometalinter') . ' .'
\ ale_linters#go#gometalinter#GetCommand(bufnr(''))

View File

@ -1,12 +1,10 @@
Before: Before:
runtime ale_linters/go/gosimple.vim call ale#assert#SetUpLinterTest('go', 'gosimple')
call ale#test#SetFilename('../go_files/testfile2.go') call ale#test#SetFilename('../go_files/testfile2.go')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
Execute(The default gosimple command should be correct): Execute(The default gosimple command should be correct):
AssertEqual 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' AssertLinter 'gosimple',
\ . ' gosimple .', \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && gosimple .'
\ ale_linters#go#gosimple#GetCommand(bufnr(''))

View File

@ -1,15 +1,15 @@
Before: Before:
runtime ale_linters/go/gotype.vim call ale#assert#SetUpLinterTest('go', 'gotype')
call ale#test#SetFilename('../go_files/testfile2.go') call ale#test#SetFilename('../go_files/testfile2.go')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
Execute(The default gotype command should be correct): Execute(The default gotype command should be correct):
AssertEqual 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' AssertLinter 'gotype',
\ . ' gotype .', \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && gotype .'
\ ale_linters#go#gotype#GetCommand(bufnr(''))
Execute(The gotype callback should ignore test files): Execute(The gotype callback should ignore test files):
call ale#test#SetFilename('bla_test.go') call ale#test#SetFilename('bla_test.go')
AssertEqual 0, ale_linters#go#gotype#GetCommand(bufnr(''))
AssertLinter 'gotype', ''

View File

@ -1,16 +1,8 @@
Before: Before:
runtime ale_linters/go/govet.vim call ale#assert#SetUpLinterTest('go', 'govet')
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
call ale#test#RestoreDirectory()
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet .'
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ' go vet .',
\ ale_linters#go#govet#GetCommand(bufnr(''))

View File

@ -1,72 +1,37 @@
Before: Before:
runtime ale_linters/haml/hamllint.vim call ale#assert#SetUpLinterTest('haml', 'hamllint')
let g:default_command = 'haml-lint %t' let g:default_command = 'haml-lint %t'
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore
unlet! g:default_command
unlet! b:conf unlet! b:conf
unlet! b:conf_hamllint
unlet! b:conf_rubocop
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual g:default_command, ale_linters#haml#hamllint#GetCommand(bufnr('')) AssertLinter 'haml-lint', 'haml-lint %t'
Execute(The command should have the .rubocop.yml prepended as an env var if one exists): Execute(The command should have the .rubocop.yml prepended as an env var if one exists):
call ale#test#SetFilename('../hamllint-test-files/rubocop-yml/subdir/file.haml') call ale#test#SetFilename('../hamllint-test-files/rubocop-yml/subdir/file.haml')
let b:conf = ale#path#Simplify(g:dir . '/../hamllint-test-files/rubocop-yml/.rubocop.yml') let b:conf = ale#path#Simplify(g:dir . '/../hamllint-test-files/rubocop-yml/.rubocop.yml')
if has('win32') AssertLinter 'haml-lint',
" Windows uses 'set var=... && command' \ ale#Env('HAML_LINT_RUBOCOP_CONF', b:conf) . 'haml-lint %t'
AssertEqual
\ 'set HAML_LINT_RUBOCOP_CONF='
\ . ale#Escape(b:conf)
\ . ' && ' . g:default_command,
\ ale_linters#haml#hamllint#GetCommand(bufnr(''))
else
" Unix uses 'var=... command'
AssertEqual
\ 'HAML_LINT_RUBOCOP_CONF='
\ . ale#Escape(b:conf)
\ . ' ' . g:default_command,
\ ale_linters#haml#hamllint#GetCommand(bufnr(''))
endif
Execute(The command should have the nearest .haml-lint.yml set as --config if it exists): Execute(The command should have the nearest .haml-lint.yml set as --config if it exists):
call ale#test#SetFilename('../hamllint-test-files/haml-lint-yml/subdir/file.haml') call ale#test#SetFilename('../hamllint-test-files/haml-lint-yml/subdir/file.haml')
let b:conf = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-yml/.haml-lint.yml') let b:conf = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-yml/.haml-lint.yml')
AssertEqual AssertLinter 'haml-lint',
\ 'haml-lint --config ' \ 'haml-lint --config ' . ale#Escape(b:conf) . ' %t',
\ . ale#Escape(b:conf)
\ . ' %t',
\ ale_linters#haml#hamllint#GetCommand(bufnr(''))
Execute(The command should include a .rubocop.yml and a .haml-lint if both are found): Execute(The command should include a .rubocop.yml and a .haml-lint if both are found):
call ale#test#SetFilename('../hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml') call ale#test#SetFilename('../hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml')
let b:conf_hamllint = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml') let b:conf_hamllint = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml')
let b:conf_rubocop = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml') let b:conf_rubocop = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml')
if has('win32') AssertLinter 'haml-lint',
" Windows uses 'set var=... && command' \ ale#Env('HAML_LINT_RUBOCOP_CONF', b:conf_rubocop)
AssertEqual \ . 'haml-lint --config ' . ale#Escape(b:conf_hamllint) . ' %t'
\ 'set HAML_LINT_RUBOCOP_CONF='
\ . ale#Escape(b:conf_rubocop)
\ . ' && haml-lint --config '
\ . ale#Escape(b:conf_hamllint)
\ . ' %t',
\ ale_linters#haml#hamllint#GetCommand(bufnr(''))
else
" Unix uses 'var=... command'
AssertEqual
\ 'HAML_LINT_RUBOCOP_CONF='
\ . ale#Escape(b:conf_rubocop)
\ . ' haml-lint --config '
\ . ale#Escape(b:conf_hamllint)
\ . ' %t',
\ ale_linters#haml#hamllint#GetCommand(bufnr(''))
endif

View File

@ -1,23 +1,12 @@
Before: Before:
Save g:ale_haskell_ghc_options call ale#assert#SetUpLinterTest('haskell', 'ghc')
unlet! g:ale_haskell_ghc_options
unlet! b:ale_haskell_ghc_options
runtime ale_linters/haskell/ghc.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:ale_haskell_ghc_options
call ale#linter#Reset()
Execute(The options should be used in the command): Execute(The options should be used in the command):
AssertEqual AssertLinter 'ghc', 'ghc -fno-code -v0 %t'
\ 'ghc -fno-code -v0 %t',
\ ale_linters#haskell#ghc#GetCommand(bufnr(''))
let b:ale_haskell_ghc_options = 'foobar' let b:ale_haskell_ghc_options = 'foobar'
AssertEqual AssertLinter 'ghc', 'ghc foobar %t'
\ 'ghc foobar %t',
\ ale_linters#haskell#ghc#GetCommand(bufnr(''))

View File

@ -1,37 +1,16 @@
Before: Before:
Save g:ale_haskell_hdevtools_executable call ale#assert#SetUpLinterTest('haskell', 'hdevtools')
Save g:ale_haskell_hdevtools_options
unlet! g:ale_haskell_hdevtools_executable
unlet! b:ale_haskell_hdevtools_executable
unlet! g:ale_haskell_hdevtools_options
unlet! b:ale_haskell_hdevtools_options
runtime ale_linters/haskell/hdevtools.vim
let b:command_tail = ' check -g -Wall -p %s %t' let b:command_tail = ' check -g -Wall -p %s %t'
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_haskell_hdevtools_executable
unlet! b:ale_haskell_hdevtools_options call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'hdevtools', ale_linters#haskell#hdevtools#GetExecutable(bufnr('')) AssertLinter 'hdevtools', ale#Escape('hdevtools') . b:command_tail
let b:ale_haskell_hdevtools_executable = 'foobar' let b:ale_haskell_hdevtools_executable = 'foobar'
AssertEqual 'foobar', ale_linters#haskell#hdevtools#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('hdevtools') . b:command_tail,
\ ale_linters#haskell#hdevtools#GetCommand(bufnr(''))
let b:ale_haskell_hdevtools_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . b:command_tail,
\ ale_linters#haskell#hdevtools#GetCommand(bufnr(''))

View File

@ -1,71 +1,51 @@
Before: Before:
Save g:ale_html_htmlhint_options call ale#assert#SetUpLinterTest('html', 'htmlhint')
Save g:ale_html_htmlhint_executable
Save g:ale_html_htmlhint_use_global
unlet! g:ale_html_htmlhint_options
unlet! g:ale_html_htmlhint_executable
unlet! g:ale_html_htmlhint_use_global
runtime ale_linters/html/htmlhint.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('htmlhint_paths/test.html') call ale#test#SetFilename('htmlhint_paths/test.html')
let g:node_executable = ale#path#Simplify( let g:node_executable = ale#path#Simplify(
\ g:dir \ g:dir . '/htmlhint_paths/node_modules/.bin/htmlhint'
\ . '/htmlhint_paths/node_modules/.bin/htmlhint'
\) \)
let g:config_path = ale#path#Simplify( let g:config_path = ale#path#Simplify(
\ g:dir \ g:dir . '/htmlhint_paths/with_config/.htmlhintrc'
\ . '/htmlhint_paths/with_config/.htmlhintrc'
\) \)
After: After:
Restore
unlet! g:node_executable unlet! g:node_executable
unlet! g:config_path unlet! g:config_path
call ale#test#RestoreDirectory() call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual AssertLinter g:node_executable,
\ ale#Escape(g:node_executable) . ' --format=unix %t', \ ale#Escape(g:node_executable) . ' --format=unix %t'
\ ale_linters#html#htmlhint#GetCommand(bufnr(''))
Execute(The global executable should be uesd if the option is set): Execute(The global executable should be uesd if the option is set):
let g:ale_html_htmlhint_executable = 'foo' let g:ale_html_htmlhint_executable = 'foo'
let g:ale_html_htmlhint_use_global = 1 let g:ale_html_htmlhint_use_global = 1
AssertEqual AssertLinter 'foo', ale#Escape('foo') . ' --format=unix %t',
\ ale#Escape('foo') . ' --format=unix %t',
\ ale_linters#html#htmlhint#GetCommand(bufnr(''))
" This is so old configurations which might include this still work. " This is so old configurations which might include this still work.
Execute(--format=unix should be removed from the options if added): Execute(--format=unix should be removed from the options if added):
let g:ale_html_htmlhint_options = '--format=unix' let g:ale_html_htmlhint_options = '--format=unix'
AssertEqual AssertLinter g:node_executable,
\ ale#Escape(g:node_executable) . ' --format=unix %t', \ ale#Escape(g:node_executable) . ' --format=unix %t'
\ ale_linters#html#htmlhint#GetCommand(bufnr(''))
Execute(The configuration file should be automatically detected): Execute(The configuration file should be automatically detected):
call ale#test#SetFilename('htmlhint_paths/with_config/test.html') call ale#test#SetFilename('htmlhint_paths/with_config/test.html')
AssertEqual AssertLinter g:node_executable,
\ ale#Escape(g:node_executable) \ ale#Escape(g:node_executable)
\ . ' --config ' . ale#Escape(g:config_path) \ . ' --config ' . ale#Escape(g:config_path)
\ . ' --format=unix %t', \ . ' --format=unix %t'
\ ale_linters#html#htmlhint#GetCommand(bufnr(''))
" This is so old configurations which might include the config will work. " This is so old configurations which might include the config will work.
Execute(The configuration file should be configurable through the options variable): Execute(The configuration file should be configurable through the options variable):
call ale#test#SetFilename('htmlhint_paths/with_config/test.html') call ale#test#SetFilename('htmlhint_paths/with_config/test.html')
let g:ale_html_htmlhint_options = '--config=/foo/bar/.htmlhintrc' let g:ale_html_htmlhint_options = '--config=/foo/bar/.htmlhintrc'
AssertEqual AssertLinter g:node_executable,
\ ale#Escape(g:node_executable) \ ale#Escape(g:node_executable)
\ . ' --config=/foo/bar/.htmlhintrc' \ . ' --config=/foo/bar/.htmlhintrc'
\ . ' --format=unix %t', \ . ' --format=unix %t'
\ ale_linters#html#htmlhint#GetCommand(bufnr(''))

View File

@ -1,42 +1,21 @@
Before: Before:
Save g:ale_idris_idris_executable call ale#assert#SetUpLinterTest('idris', 'idris')
Save g:ale_idris_idris_options
unlet! g:ale_idris_idris_executable
unlet! b:ale_idris_idris_executable
unlet! g:ale_idris_idris_options
unlet! b:ale_idris_idris_options
runtime ale_linters/idris/idris.vim
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_idris_idris_executable
unlet! b:ale_idris_idris_options
call ale#linter#Reset()
Execute(The executable should be configurable): call ale#assert#TearDownLinterTest()
AssertEqual 'idris', ale_linters#idris#idris#GetExecutable(bufnr(''))
let b:ale_idris_idris_executable = 'foobar'
AssertEqual 'foobar', ale_linters#idris#idris#GetExecutable(bufnr(''))
Execute(The executable should be used in the command): Execute(The executable should be used in the command):
AssertEqual AssertLinter 'idris',
\ ale#Escape('idris') . ' --total --warnpartial --warnreach --warnipkg --check %s', \ ale#Escape('idris') . ' --total --warnpartial --warnreach --warnipkg --check %s'
\ ale_linters#idris#idris#GetCommand(bufnr(''))
let b:ale_idris_idris_executable = 'foobar' let b:ale_idris_idris_executable = 'foobar'
AssertEqual AssertLinter 'foobar',
\ ale#Escape('foobar') . ' --total --warnpartial --warnreach --warnipkg --check %s', \ ale#Escape('foobar') . ' --total --warnpartial --warnreach --warnipkg --check %s'
\ ale_linters#idris#idris#GetCommand(bufnr(''))
Execute(The options should be configurable): Execute(The options should be configurable):
let b:ale_idris_idris_options = '--something' let b:ale_idris_idris_options = '--something'
AssertEqual AssertLinter 'idris', ale#Escape('idris') . ' --something --check %s'
\ ale#Escape('idris') . ' --something --check %s',
\ ale_linters#idris#idris#GetCommand(bufnr(''))

View File

@ -1,24 +1,14 @@
Before: Before:
Save g:ale_verilog_iverilog_options call ale#assert#SetUpLinterTest('verilog', 'iverilog')
unlet! g:ale_verilog_iverilog_options
runtime ale_linters/verilog/iverilog.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The default iverilog command should be correct): Execute(The default iverilog command should be correct):
AssertEqual AssertLinter 'iverilog', 'iverilog -t null -Wall %t'
\ 'iverilog -t null -Wall %t',
\ ale_linters#verilog#iverilog#GetCommand(bufnr(''))
Execute(iverilog options should be configurable): Execute(iverilog options should be configurable):
" Additional args for the linter " Additional args for the linter
let g:ale_verilog_iverilog_options = '-y.' let g:ale_verilog_iverilog_options = '-y.'
AssertEqual AssertLinter 'iverilog', 'iverilog -t null -Wall -y. %t'
\ 'iverilog -t null -Wall -y. %t',
\ ale_linters#verilog#iverilog#GetCommand(bufnr(''))

View File

@ -1,15 +1,10 @@
Before: Before:
call ale#test#SetDirectory('/testplugin/test/command_callback') call ale#assert#SetUpLinterTest('java', 'javac')
call ale#test#SetFilename('dummy.java')
Save g:ale_java_javac_executable
Save g:ale_java_javac_options
Save g:ale_java_javac_classpath
unlet! g:ale_java_javac_executable
unlet! g:ale_java_javac_options
unlet! g:ale_java_javac_classpath
let g:cp_sep = has('unix') ? ':' : ';' let g:cp_sep = has('unix') ? ':' : ';'
let g:prefix = 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('javac') . ' -Xlint'
function! GetCommand(previous_output) abort function! GetCommand(previous_output) abort
let l:command = ale_linters#java#javac#GetCommand( let l:command = ale_linters#java#javac#GetCommand(
@ -25,69 +20,58 @@ Before:
return join(l:split_command) return join(l:split_command)
endfunction endfunction
runtime ale_linters/java/javac.vim
call ale#engine#InitBufferInfo(bufnr(''))
call ale#test#SetFilename('dummy.java')
let g:prefix = 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('javac') . ' -Xlint'
After: After:
call ale#test#RestoreDirectory()
Restore
unlet! g:cp_sep unlet! g:cp_sep
unlet! g:prefix unlet! g:prefix
delfunction GetCommand delfunction GetCommand
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
" We need to clean up the buffer to remove the temporary directories created
" for the command.
call ale#engine#Cleanup(bufnr(''))
Execute(The javac callback should return the correct default value): Execute(The javac callback should return the correct default value):
AssertEqual g:prefix . ' -d TEMP %t', GetCommand([]) AssertLinter 'javac', g:prefix . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should use g:ale_java_javac_classpath correctly): Execute(The javac callback should use g:ale_java_javac_classpath correctly):
let g:ale_java_javac_classpath = 'foo.jar' let g:ale_java_javac_classpath = 'foo.jar'
AssertEqual AssertLinter 'javac',
\ g:prefix \ g:prefix
\ . ' -cp ' . ale#Escape('foo.jar') \ . ' -cp ' . ale#Escape('foo.jar')
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([])
Execute(The executable should be configurable): Execute(The executable should be configurable):
let g:ale_java_javac_executable = 'foobar' let g:ale_java_javac_executable = 'foobar'
AssertEqual 'foobar', ale_linters#java#javac#GetExecutable(bufnr('')) AssertLinter 'foobar',
AssertEqual
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('foobar') . ' -Xlint' \ . ale#Escape('foobar') . ' -Xlint'
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([])
Execute(The javac callback should include discovered classpaths): Execute(The javac callback should include discovered classpaths):
AssertEqual WithChainResults [
\ '[DEBUG] Ignore this.',
\ '[INFO] Something we should ignore.',
\ '/foo/bar.jar',
\ '/xyz/abc.jar',
\]
AssertLinter 'javac',
\ g:prefix \ g:prefix
\ . ' -cp ' \ . ' -cp '
\ . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep)) \ . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([
\ '[DEBUG] Ignore this.',
\ '[INFO] Something we should ignore.',
\ '/foo/bar.jar',
\ '/xyz/abc.jar',
\ ])
Execute(The javac callback should combine discovered classpaths and manual ones): Execute(The javac callback should combine discovered classpaths and manual ones):
let g:ale_java_javac_classpath = 'configured.jar' let g:ale_java_javac_classpath = 'configured.jar'
AssertEqual WithChainResults [
\ '[DEBUG] Ignore this.',
\ '[INFO] Something we should ignore.',
\ '/foo/bar.jar',
\ '/xyz/abc.jar',
\]
AssertLinter 'javac',
\ g:prefix \ g:prefix
\ . ' -cp ' \ . ' -cp '
\ . ale#Escape(join( \ . ale#Escape(join(
@ -98,17 +82,11 @@ Execute(The javac callback should combine discovered classpaths and manual ones)
\ ], \ ],
\ g:cp_sep \ g:cp_sep
\ )) \ ))
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([
\ '[DEBUG] Ignore this.',
\ '[INFO] Something we should ignore.',
\ '/foo/bar.jar',
\ '/xyz/abc.jar',
\ ])
let g:ale_java_javac_classpath = 'configured.jar' . g:cp_sep . 'configured2.jar' let g:ale_java_javac_classpath = 'configured.jar' . g:cp_sep . 'configured2.jar'
AssertEqual AssertLinter 'javac',
\ g:prefix \ g:prefix
\ . ' -cp ' \ . ' -cp '
\ . ale#Escape(join( \ . ale#Escape(join(
@ -120,55 +98,46 @@ Execute(The javac callback should combine discovered classpaths and manual ones)
\ ], \ ],
\ g:cp_sep \ g:cp_sep
\ )) \ ))
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([
\ '[DEBUG] Ignore this.',
\ '[INFO] Something we should ignore.',
\ '/foo/bar.jar',
\ '/xyz/abc.jar',
\ ])
Execute(The javac callback should detect source directories): Execute(The javac callback should detect source directories):
call ale#engine#Cleanup(bufnr('')) call ale#engine#Cleanup(bufnr(''))
noautocmd e! java_paths/src/main/java/com/something/dummy noautocmd e! java_paths/src/main/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr('')) call ale#engine#InitBufferInfo(bufnr(''))
AssertEqual AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape( \ . ' -sourcepath ' . ale#Escape(
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/') \ ale#path#Simplify(g:dir . '/java_paths/src/main/java/')
\ ) \ )
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([])
Execute(The javac callback should combine detected source directories and classpaths): Execute(The javac callback should combine detected source directories and classpaths):
call ale#engine#Cleanup(bufnr('')) call ale#engine#Cleanup(bufnr(''))
call ale#test#SetFilename('java_paths/src/main/java/com/something/dummy.java') call ale#test#SetFilename('java_paths/src/main/java/com/something/dummy.java')
call ale#engine#InitBufferInfo(bufnr('')) call ale#engine#InitBufferInfo(bufnr(''))
AssertEqual WithChainResults [
\ '[DEBUG] Ignore this.',
\ '[INFO] Something we should ignore.',
\ '/foo/bar.jar',
\ '/xyz/abc.jar',
\]
AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -cp ' . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep)) \ . ' -cp ' . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
\ . ' -sourcepath ' . ale#Escape( \ . ' -sourcepath ' . ale#Escape(
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/') \ ale#path#Simplify(g:dir . '/java_paths/src/main/java/')
\ ) \ )
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([
\ '[DEBUG] Ignore this.',
\ '[INFO] Something we should ignore.',
\ '/foo/bar.jar',
\ '/xyz/abc.jar',
\ ])
Execute(The javac callback should use g:ale_java_javac_options correctly): Execute(The javac callback should use g:ale_java_javac_options correctly):
let g:ale_java_javac_options = '--anything --else' let g:ale_java_javac_options = '--anything --else'
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), []) let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
AssertEqual AssertLinter 'javac',
\ g:prefix \ g:prefix . ' -d ' . ale#Escape('TEMP_DIR') . ' --anything --else %t'
\ . ' -d TEMP --anything --else %t',
\ GetCommand([])
Execute(The javac callback should include src/test/java for test paths): Execute(The javac callback should include src/test/java for test paths):
call ale#engine#Cleanup(bufnr('')) call ale#engine#Cleanup(bufnr(''))
@ -177,25 +146,23 @@ Execute(The javac callback should include src/test/java for test paths):
noautocmd e! java_paths/src/test/java/com/something/dummy noautocmd e! java_paths/src/test/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr('')) call ale#engine#InitBufferInfo(bufnr(''))
AssertEqual AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape(join([ \ . ' -sourcepath ' . ale#Escape(join([
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/'), \ ale#path#Simplify(g:dir . '/java_paths/src/main/java/'),
\ ale#path#Simplify(g:dir . '/java_paths/src/test/java/'), \ ale#path#Simplify(g:dir . '/java_paths/src/test/java/'),
\ ], g:cp_sep)) \ ], g:cp_sep))
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([])
Execute(The javac callback should include src/main/jaxb when available): Execute(The javac callback should include src/main/jaxb when available):
call ale#engine#Cleanup(bufnr('')) call ale#engine#Cleanup(bufnr(''))
noautocmd e! java_paths_with_jaxb/src/main/java/com/something/dummy noautocmd e! java_paths_with_jaxb/src/main/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr('')) call ale#engine#InitBufferInfo(bufnr(''))
AssertEqual AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape(join([ \ . ' -sourcepath ' . ale#Escape(join([
\ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/java/'), \ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/java/'),
\ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/jaxb/'), \ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/jaxb/'),
\ ], g:cp_sep)) \ ], g:cp_sep))
\ . ' -d TEMP %t', \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
\ GetCommand([])

View File

@ -1,25 +1,15 @@
Before: Before:
runtime ale_linters/javascript/jscs.vim call ale#assert#SetUpLinterTest('javascript', 'jscs')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
let g:ale_javascript_jscs_executable = 'jscs'
Execute(Should return the correct default values): Execute(Should return the correct default values):
AssertEqual AssertLinter 'jscs',
\ 'jscs', \ ale#Escape('jscs') . ' --reporter inline --no-colors -'
\ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('jscs') . ' --reporter inline --no-colors -',
\ ale_linters#javascript#jscs#GetCommand(bufnr(''))
Execute(Should allow using a custom executable): Execute(Should allow using a custom executable):
let g:ale_javascript_jscs_executable = 'foobar' let g:ale_javascript_jscs_executable = 'foobar'
AssertEqual AssertLinter 'foobar',
\ 'foobar', \ ale#Escape('foobar') . ' --reporter inline --no-colors -'
\ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('foobar') . ' --reporter inline --no-colors -',
\ ale_linters#javascript#jscs#GetCommand(bufnr(''))

View File

@ -1,31 +1,10 @@
Before: Before:
Save g:ale_less_stylelint_executable call ale#assert#SetUpLinterTest('less', 'stylelint')
Save g:ale_less_stylelint_use_global
Save g:ale_less_stylelint_options
unlet! b:executable unlet! b:executable
unlet! g:ale_less_stylelint_executable
unlet! g:ale_less_stylelint_use_global
unlet! g:ale_less_stylelint_options
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('testfile.less')
runtime ale_linters/less/stylelint.vim
After: After:
Restore
unlet! b:executable unlet! b:executable
unlet! b:ale_less_stylelint_executable call ale#assert#TearDownLinterTest()
unlet! b:ale_less_stylelint_use_global
unlet! b:ale_less_stylelint_options
call ale#test#SetFilename('test.txt')
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(node_modules directories should be discovered): Execute(node_modules directories should be discovered):
call ale#test#SetFilename('stylelint_paths/nested/testfile.less') call ale#test#SetFilename('stylelint_paths/nested/testfile.less')
@ -35,10 +14,7 @@ Execute(node_modules directories should be discovered):
\ . '/stylelint_paths/node_modules/.bin/stylelint' \ . '/stylelint_paths/node_modules/.bin/stylelint'
\) \)
AssertEqual b:executable, ale_linters#less#stylelint#GetExecutable(bufnr('')) AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin-filename %s'
AssertEqual
\ ale#Escape(b:executable) . ' --stdin-filename %s',
\ ale_linters#less#stylelint#GetCommand(bufnr(''))
Execute(The global override should work): Execute(The global override should work):
let b:ale_less_stylelint_executable = 'foobar' let b:ale_less_stylelint_executable = 'foobar'
@ -46,15 +22,10 @@ Execute(The global override should work):
call ale#test#SetFilename('stylelint_paths/nested/testfile.less') call ale#test#SetFilename('stylelint_paths/nested/testfile.less')
AssertEqual 'foobar', ale_linters#less#stylelint#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin-filename %s'
AssertEqual
\ ale#Escape('foobar') . ' --stdin-filename %s',
\ ale_linters#less#stylelint#GetCommand(bufnr(''))
Execute(Extra options should be configurable): Execute(Extra options should be configurable):
let b:ale_less_stylelint_options = '--whatever' let b:ale_less_stylelint_options = '--whatever'
AssertEqual 'stylelint', ale_linters#less#stylelint#GetExecutable(bufnr('')) AssertLinter 'stylelint',
AssertEqual \ ale#Escape('stylelint') . ' --whatever --stdin-filename %s'
\ ale#Escape('stylelint') . ' --whatever --stdin-filename %s',
\ ale_linters#less#stylelint#GetCommand(bufnr(''))

View File

@ -1,31 +1,13 @@
Before: Before:
Save g:ale_less_lessc_executable call ale#assert#SetUpLinterTest('less', 'lessc')
Save g:ale_less_lessc_use_global
Save g:ale_less_lessc_options
unlet! b:executable
unlet! g:ale_less_lessc_executable
unlet! g:ale_less_lessc_use_global
unlet! g:ale_less_lessc_options
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('testfile.less') call ale#test#SetFilename('testfile.less')
runtime ale_linters/less/lessc.vim unlet! b:executable
After: After:
Restore
unlet! b:executable unlet! b:executable
unlet! b:ale_less_lessc_executable
unlet! b:ale_less_lessc_use_global
unlet! b:ale_less_lessc_options
call ale#test#SetFilename('test.txt') call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(node_modules directories should be discovered): Execute(node_modules directories should be discovered):
call ale#test#SetFilename('lessc_paths/nested/testfile.less') call ale#test#SetFilename('lessc_paths/nested/testfile.less')
@ -35,17 +17,11 @@ Execute(node_modules directories should be discovered):
\ . '/lessc_paths/node_modules/.bin/lessc' \ . '/lessc_paths/node_modules/.bin/lessc'
\) \)
AssertEqual AssertLinter b:executable, ale#Escape(b:executable)
\ b:executable, \ . ' --no-color --lint'
\ ale_linters#less#lessc#GetExecutable(bufnr('')) \ . ' --include-path='
\ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
AssertEqual \ . ' -'
\ ale#Escape(b:executable)
\ . ' --no-color --lint'
\ . ' --include-path='
\ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
\ . ' -',
\ ale_linters#less#lessc#GetCommand(bufnr(''))
Execute(The global override should work): Execute(The global override should work):
let b:ale_less_lessc_executable = 'foobar' let b:ale_less_lessc_executable = 'foobar'
@ -53,30 +29,18 @@ Execute(The global override should work):
call ale#test#SetFilename('lessc_paths/nested/testfile.less') call ale#test#SetFilename('lessc_paths/nested/testfile.less')
AssertEqual AssertLinter 'foobar', ale#Escape('foobar')
\ 'foobar', \ . ' --no-color --lint'
\ ale_linters#less#lessc#GetExecutable(bufnr('')) \ . ' --include-path='
\ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
AssertEqual \ . ' -'
\ ale#Escape('foobar')
\ . ' --no-color --lint'
\ . ' --include-path='
\ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
\ . ' -',
\ ale_linters#less#lessc#GetCommand(bufnr(''))
Execute(Extra options should be configurable): Execute(Extra options should be configurable):
let b:ale_less_lessc_options = '--whatever' let b:ale_less_lessc_options = '--whatever'
AssertEqual AssertLinter 'lessc', ale#Escape('lessc')
\ 'lessc', \ . ' --no-color --lint'
\ ale_linters#less#lessc#GetExecutable(bufnr('')) \ . ' --include-path='
\ . ale#Escape(ale#path#Simplify(g:dir))
AssertEqual \ . ' --whatever'
\ ale#Escape('lessc') \ . ' -'
\ . ' --no-color --lint'
\ . ' --include-path='
\ . ale#Escape(ale#path#Simplify(g:dir))
\ . ' --whatever'
\ . ' -',
\ ale_linters#less#lessc#GetCommand(bufnr(''))

View File

@ -1,48 +1,36 @@
Before: Before:
Save g:ale_r_lintr_options call ale#assert#SetUpLinterTest('r', 'lintr')
unlet! g:ale_r_lintr_options
unlet! b:ale_r_lintr_options
runtime ale_linters/r/lintr.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:ale_r_lintr_options
call ale#linter#Reset()
Execute(The default lintr command should be correct): Execute(The default lintr command should be correct):
AssertEqual AssertLinter 'Rscript',
\ 'cd ' . ale#Escape(getcwd()) . ' && ' \ 'cd ' . ale#Escape(getcwd()) . ' && '
\ . 'Rscript --vanilla -e ' \ . 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
\ . 'lint(cache = FALSE, commandArgs(TRUE), ' \ . 'lint(cache = FALSE, commandArgs(TRUE), '
\ . 'with_defaults())') \ . 'with_defaults())')
\ . ' %t', \ . ' %t'
\ ale_linters#r#lintr#GetCommand(bufnr(''))
Execute(The lintr options should be configurable): Execute(The lintr options should be configurable):
let b:ale_r_lintr_options = 'with_defaults(object_usage_linter = NULL)' let b:ale_r_lintr_options = 'with_defaults(object_usage_linter = NULL)'
AssertEqual AssertLinter 'Rscript',
\ 'cd ' . ale#Escape(getcwd()) . ' && ' \ 'cd ' . ale#Escape(getcwd()) . ' && '
\ . 'Rscript --vanilla -e ' \ . 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
\ . 'lint(cache = FALSE, commandArgs(TRUE), ' \ . 'lint(cache = FALSE, commandArgs(TRUE), '
\ . 'with_defaults(object_usage_linter = NULL))') \ . 'with_defaults(object_usage_linter = NULL))')
\ . ' %t', \ . ' %t'
\ ale_linters#r#lintr#GetCommand(bufnr(''))
Execute(If the lint_package flag is set, lintr::lint_package should be called): Execute(If the lint_package flag is set, lintr::lint_package should be called):
let b:ale_r_lintr_lint_package = 1 let b:ale_r_lintr_lint_package = 1
AssertEqual AssertLinter 'Rscript',
\ 'cd ' . ale#Escape(getcwd()) . ' && ' \ 'cd ' . ale#Escape(getcwd()) . ' && '
\ . 'Rscript --vanilla -e ' \ . 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
\ . 'lint_package(cache = FALSE, ' \ . 'lint_package(cache = FALSE, '
\ . 'linters = with_defaults())') \ . 'linters = with_defaults())')
\ . ' %t', \ . ' %t'
\ ale_linters#r#lintr#GetCommand(bufnr(''))

View File

@ -1,10 +1,5 @@
Before: Before:
Save g:ale_llvm_llc_executable call ale#assert#SetUpLinterTest('llvm', 'llc')
unlet! g:ale_llvm_llc_executable
unlet! b:ale_llvm_llc_executable
runtime ale_linters/llvm/llc.vim
function! AssertHasPrefix(str, prefix) abort function! AssertHasPrefix(str, prefix) abort
let msg = printf("'%s' is expected to be prefixed with '%s'", a:str, a:prefix) let msg = printf("'%s' is expected to be prefixed with '%s'", a:str, a:prefix)
@ -12,28 +7,15 @@ Before:
endfunction endfunction
After: After:
unlet! g:ale_llvm_llc_executable
unlet! b:ale_llvm_llc_executable
delfunction AssertHasPrefix delfunction AssertHasPrefix
Restore
Execute(llc command is customizable): call ale#assert#TearDownLinterTest()
let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
call AssertHasPrefix(cmd, ale#Escape('llc')) Execute(The llc command should be customizable):
AssertLinter 'llc',
\ ale#Escape('llc') . ' -filetype=null -o=' . g:ale#util#nul_file
let g:ale_llvm_llc_executable = 'llc-5.0' let g:ale_llvm_llc_executable = 'llc-5.0'
let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
call AssertHasPrefix(cmd, ale#Escape('llc-5.0'))
let b:ale_llvm_llc_executable = 'llc-4.0' AssertLinter 'llc-5.0',
let cmd = ale_linters#llvm#llc#GetCommand(bufnr('')) \ ale#Escape('llc-5.0') . ' -filetype=null -o=' . g:ale#util#nul_file
call AssertHasPrefix(cmd, ale#Escape('llc-4.0'))
Execute(GetCommand() escapes the returned path):
let b:ale_llvm_llc_executable = '/path/space contained/llc'
let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
call AssertHasPrefix(cmd, ale#Escape('/path/space contained/llc'))
Execute(GetExecutable() does not escape the returned path):
let b:ale_llvm_llc_executable = '/path/space contained/llc'
AssertEqual ale_linters#llvm#llc#GetExecutable(bufnr('')), '/path/space contained/llc'

View File

@ -1,16 +1,13 @@
Before: Before:
runtime ale_linters/lua/luac.vim call ale#assert#SetUpLinterTest('lua', 'luac')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual ale#Escape('luac') . ' -p -', AssertLinter 'luac', ale#Escape('luac') . ' -p - '
\ join(split(ale_linters#lua#luac#GetCommand(1)))
Execute(The luac executable should be configurable): Execute(The luac executable should be configurable):
let g:ale_lua_luac_executable = 'luac.sh' let g:ale_lua_luac_executable = 'luac.sh'
AssertEqual 'luac.sh', ale_linters#lua#luac#GetExecutable(1) AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p - '
AssertEqual ale#Escape('luac.sh') . ' -p -',
\ join(split(ale_linters#lua#luac#GetCommand(1)))

View File

@ -1,24 +1,23 @@
Before: Before:
runtime ale_linters/lua/luacheck.vim call ale#assert#SetUpLinterTest('lua', 'luacheck')
After: After:
call ale#linter#Reset() call ale#assert#TearDownLinterTest()
let g:ale_lua_luacheck_options = ''
let g:ale_lua_luacheck_executable = 'luacheck'
Execute(The lua luacheck command callback should return the correct default string): Execute(The lua luacheck command callback should return the correct default string):
AssertEqual ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -', AssertLinter 'luacheck',
\ join(split(ale_linters#lua#luacheck#GetCommand(1))) \ ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -'
Execute(The lua luacheck command callback should let you set options): Execute(The lua luacheck command callback should let you set options):
let g:ale_lua_luacheck_options = '--config filename' let g:ale_lua_luacheck_options = '--config filename'
AssertEqual ale#Escape('luacheck') . ' --config filename --formatter plain --codes --filename %s -', AssertLinter 'luacheck',
\ join(split(ale_linters#lua#luacheck#GetCommand(1))) \ ale#Escape('luacheck')
\ . ' --config filename'
\ . ' --formatter plain --codes --filename %s -'
Execute(The luacheck executable should be configurable): Execute(The luacheck executable should be configurable):
let g:ale_lua_luacheck_executable = 'luacheck.sh' let g:ale_lua_luacheck_executable = 'luacheck.sh'
AssertEqual 'luacheck.sh', ale_linters#lua#luacheck#GetExecutable(1) AssertLinter 'luacheck.sh',
AssertEqual ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -', \ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -'
\ join(split(ale_linters#lua#luacheck#GetCommand(1)))

View File

@ -1,35 +1,19 @@
Before: Before:
Save g:ale_markdown_mdl_executable call ale#assert#SetUpLinterTest('markdown', 'mdl')
Save g:ale_markdown_mdl_options
unlet! g:ale_markdown_mdl_executable
unlet! g:ale_markdown_mdl_options
runtime ale_linters/markdown/mdl.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual ale_linters#markdown#mdl#GetExecutable(bufnr('')), 'mdl' AssertLinter 'mdl', ale#Escape('mdl')
AssertEqual
\ ale_linters#markdown#mdl#GetCommand(bufnr('')),
\ ale#Escape('mdl')
Execute(The executable and options should be configurable): Execute(The executable and options should be configurable):
let g:ale_markdown_mdl_executable = 'foo bar' let g:ale_markdown_mdl_executable = 'foo bar'
let g:ale_markdown_mdl_options = '--wat' let g:ale_markdown_mdl_options = '--wat'
AssertEqual ale_linters#markdown#mdl#GetExecutable(bufnr('')), 'foo bar' AssertLinter 'foo bar', ale#Escape('foo bar') . ' --wat'
AssertEqual
\ ale_linters#markdown#mdl#GetCommand(bufnr('')),
\ ale#Escape('foo bar') . ' --wat'
Execute(Setting bundle appends 'exec mdl'): Execute(Setting bundle appends 'exec mdl'):
let g:ale_markdown_mdl_executable = 'path to/bundle' let g:ale_markdown_mdl_executable = 'path to/bundle'
AssertEqual AssertLinter 'path to/bundle', ale#Escape('path to/bundle') . ' exec mdl'
\ ale#Escape('path to/bundle') . ' exec mdl',
\ ale_linters#markdown#mdl#GetCommand(bufnr(''))

View File

@ -1,42 +1,25 @@
Before: Before:
Save g:ale_mercury_mmc_executable call ale#assert#SetUpLinterTest('mercury', 'mmc')
Save g:ale_mercury_mmc_options call ale#test#SetFilename('dummy')
unlet! g:ale_mercury_mmc_executable
unlet! b:ale_mercury_mmc_executable
unlet! g:ale_mercury_mmc_options
unlet! b:ale_mercury_mmc_options
runtime ale_linters/mercury/mmc.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
unlet! b:ale_mercury_mmc_executable call ale#assert#TearDownLinterTest()
unlet! b:ale_mercury_mmc_options
Restore
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The default command should be correct): Execute(The default command should be correct):
AssertEqual AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . 'mmc --errorcheck-only --make --output-compile-error-lines 100 dummy', \ . 'mmc --errorcheck-only --make --output-compile-error-lines 100 dummy'
\
\ ale_linters#mercury#mmc#GetCommand(bufnr(''))
Execute(The executable should be configurable): Execute(The executable should be configurable):
let b:ale_mercury_mmc_executable = 'foo' let b:ale_mercury_mmc_executable = 'foo'
AssertEqual
AssertLinter 'foo',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . 'foo --errorcheck-only --make --output-compile-error-lines 100 dummy', \ . 'foo --errorcheck-only --make --output-compile-error-lines 100 dummy'
\
\ ale_linters#mercury#mmc#GetCommand(bufnr(''))
Execute(The options should be configurable): Execute(The options should be configurable):
let b:ale_mercury_mmc_options = '--bar' let b:ale_mercury_mmc_options = '--bar'
AssertEqual
AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . 'mmc --errorcheck-only --bar dummy', \ . 'mmc --errorcheck-only --bar dummy'
\
\ ale_linters#mercury#mmc#GetCommand(bufnr(''))

View File

@ -1,106 +1,71 @@
Before: Before:
Save g:ale_python_mypy_executable call ale#assert#SetUpLinterTest('python', 'mypy')
Save g:ale_python_mypy_options call ale#test#SetFilename('test.py')
Save g:ale_python_mypy_use_global
unlet! g:ale_python_mypy_executable
unlet! g:ale_python_mypy_options
unlet! g:ale_python_mypy_use_global
let b:bin_dir = has('win32') ? 'Scripts' : 'bin' let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
runtime ale_linters/python/mypy.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('test.py')
After: After:
Restore
unlet! b:bin_dir unlet! b:bin_dir
unlet! b:executable unlet! b:executable
call ale#test#RestoreDirectory() call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The mypy callbacks should return the correct default values): Execute(The mypy callbacks should return the correct default values):
AssertEqual AssertLinter 'mypy',
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy') \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers ' \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s', \ . '--shadow-file %s %t %s'
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy executable should be configurable, and escaped properly): Execute(The mypy executable should be configurable, and escaped properly):
let g:ale_python_mypy_executable = 'executable with spaces' let g:ale_python_mypy_executable = 'executable with spaces'
AssertEqual AssertLinter 'executable with spaces',
\ 'executable with spaces',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('executable with spaces') \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('executable with spaces')
\ . ' --show-column-numbers ' \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s', \ . '--shadow-file %s %t %s'
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy command callback should let you set options): Execute(The mypy command callback should let you set options):
let g:ale_python_mypy_options = '--some-option' let g:ale_python_mypy_options = '--some-option'
AssertEqual AssertLinter 'mypy',
\ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy') \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers --some-option ' \ . ' --show-column-numbers --some-option '
\ . '--shadow-file %s %t %s', \ . '--shadow-file %s %t %s'
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy command should switch directories to the detected project root): Execute(The mypy command should switch directories to the detected project root):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py') silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
AssertEqual AssertLinter 'mypy',
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')) \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ' && ' . ale#Escape('mypy') \ . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers ' \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s', \ . '--shadow-file %s %t %s'
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy callbacks should detect virtualenv directories and switch to the project root): Execute(The mypy callbacks should detect virtualenv directories and switch to the project root):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') 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 . '/mypy') let b:executable = ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/mypy')
AssertEqual AssertLinter b:executable,
\ b:executable,
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')) \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ' && ' . ale#Escape(b:executable) \ . ' && ' . ale#Escape(b:executable)
\ . ' --show-column-numbers ' \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s', \ . '--shadow-file %s %t %s'
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(You should able able to use the global mypy instead): Execute(You should able able to use the global mypy instead):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_mypy_use_global = 1 let g:ale_python_mypy_use_global = 1
AssertEqual AssertLinter 'mypy',
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')) \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ' && ' . ale#Escape('mypy') \ . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers ' \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s', \ . '--shadow-file %s %t %s'
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(Setting executable to 'pipenv' appends 'run mypy'): Execute(Setting executable to 'pipenv' appends 'run mypy'):
let g:ale_python_mypy_executable = 'path/to/pipenv' let g:ale_python_mypy_executable = 'path/to/pipenv'
AssertEqual AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run mypy' \ . ale#Escape('path/to/pipenv') . ' run mypy'
\ . ' --show-column-numbers --shadow-file %s %t %s', \ . ' --show-column-numbers --shadow-file %s %t %s'
\ ale_linters#python#mypy#GetCommand(bufnr(''))

View File

@ -1,42 +1,19 @@
Before: Before:
Save g:ale_tcl_nagelfar_executable call ale#assert#SetUpLinterTest('tcl', 'nagelfar')
Save g:ale_tcl_nagelfar_options
unlet! g:ale_tcl_nagelfar_executable
unlet! b:ale_tcl_nagelfar_executable
unlet! g:ale_tcl_nagelfar_options
unlet! b:ale_tcl_nagelfar_options
runtime ale_linters/tcl/nagelfar.vim
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:ale_tcl_nagelfar_executable
unlet! b:ale_tcl_nagelfar_options call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'nagelfar.tcl', ale_linters#tcl#nagelfar#GetExecutable(bufnr('')) AssertLinter 'nagelfar.tcl', ale#Escape('nagelfar.tcl') . ' %s'
let b:ale_tcl_nagelfar_executable = 'foobar' let b:ale_tcl_nagelfar_executable = 'foobar'
AssertEqual 'foobar', ale_linters#tcl#nagelfar#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('nagelfar.tcl') . ' %s',
\ ale_linters#tcl#nagelfar#GetCommand(bufnr(''))
let b:ale_tcl_nagelfar_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . ' %s',
\ ale_linters#tcl#nagelfar#GetCommand(bufnr(''))
Execute(The options should be configurable): Execute(The options should be configurable):
let b:ale_tcl_nagelfar_options = '--something' let b:ale_tcl_nagelfar_options = '--something'
AssertEqual AssertLinter 'nagelfar.tcl', ale#Escape('nagelfar.tcl') . ' --something %s'
\ ale#Escape('nagelfar.tcl') . ' --something %s',
\ ale_linters#tcl#nagelfar#GetCommand(bufnr(''))

View File

@ -1,13 +1,5 @@
Before: Before:
Save g:ale_nasm_nasm_executable call ale#assert#SetUpLinterTest('nasm', 'nasm')
Save g:ale_nasm_nasm_options
unlet! g:ale_nasm_nasm_executable
unlet! b:ale_nasm_nasm_executable
unlet! g:ale_nasm_nasm_options
unlet! b:ale_nasm_nasm_options
runtime ale_linters/nasm/nasm.vim
let b:command_tail = let b:command_tail =
\ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s' \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s'
@ -15,38 +7,25 @@ Before:
\ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s' \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s'
After: After:
Restore
unlet! b:command_tail unlet! b:command_tail
unlet! b:command_tail_opt unlet! b:command_tail_opt
unlet! b:ale_nasm_nasm_executable
unlet! b:ale_nasm_nasm_options call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The executable should be configurable): Execute(The executable should be configurable):
AssertEqual 'nasm', ale_linters#nasm#nasm#GetExecutable(bufnr('')) AssertLinter 'nasm', ale#Escape('nasm') . b:command_tail,
let b:ale_nasm_nasm_executable = '/opt/nasm/nasm'
AssertEqual '/opt/nasm/nasm', ale_linters#nasm#nasm#GetExecutable(bufnr(''))
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('nasm') . b:command_tail,
\ ale_linters#nasm#nasm#GetCommand(bufnr(''))
let b:ale_nasm_nasm_executable = '~/nasm' let b:ale_nasm_nasm_executable = '~/nasm'
AssertEqual AssertLinter '~/nasm', ale#Escape('~/nasm') . b:command_tail
\ ale#Escape('~/nasm') . b:command_tail,
\ ale_linters#nasm#nasm#GetCommand(bufnr(''))
Execute(The options should be configurable): Execute(The options should be configurable):
AssertEqual '', ale_linters#nasm#nasm#GetOptions(bufnr(''))
let b:ale_nasm_nasm_options = '-w-macro-params' let b:ale_nasm_nasm_options = '-w-macro-params'
AssertEqual '-w-macro-params', ale_linters#nasm#nasm#GetOptions(bufnr(''))
AssertLinter 'nasm', ale#Escape('nasm')
\ . ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w-macro-params %s'
Execute(The options should be used in command): Execute(The options should be used in command):
let b:ale_nasm_nasm_options = '-w+orphan-labels' let b:ale_nasm_nasm_options = '-w+orphan-labels'
AssertEqual
\ ale#Escape('nasm') . b:command_tail_opt, AssertLinter 'nasm', ale#Escape('nasm') . b:command_tail_opt
\ ale_linters#nasm#nasm#GetCommand(bufnr(''))

View File

@ -1,54 +1,40 @@
Before: Before:
call ale#assert#SetUpLinterTest('ocaml', 'ols')
Save &filetype Save &filetype
Save g:ale_ocaml_ols_executable
Save g:ale_ocaml_ols_use_global
let &filetype = 'ocaml' let &filetype = 'ocaml'
unlet! g:ale_ocaml_ols_executable
unlet! g:ale_ocaml_ols_use_global
runtime ale_linters/ocaml/ols.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The language string should be correct): Execute(The language string should be correct):
AssertEqual 'ocaml', ale#handlers#ols#GetLanguage(bufnr('')) AssertLSPLanguage 'ocaml'
Execute(The default executable should be correct): Execute(The default executable should be correct):
AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr('')) AssertLinter 'ocaml-language-server',
AssertEqual \ ale#Escape('ocaml-language-server') . ' --stdio'
\ ale#Escape('ocaml-language-server') . ' --stdio',
\ ale#handlers#ols#GetCommand(bufnr(''))
Execute(The project root should be detected correctly): Execute(The project root should be detected correctly):
AssertEqual '', ale#handlers#ols#GetProjectRoot(bufnr('')) AssertLSPProject ''
call ale#test#SetFilename('ols_paths/file.ml') call ale#test#SetFilename('ols_paths/file.ml')
AssertEqual AssertLSPProject ale#path#Simplify(g:dir . '/ols_paths')
\ ale#path#Simplify(g:dir . '/ols_paths'),
\ ale#handlers#ols#GetProjectRoot(bufnr(''))
Execute(The local executable should be used when available): Execute(The local executable should be used when available):
call ale#test#SetFilename('ols_paths/file.ml') call ale#test#SetFilename('ols_paths/file.ml')
AssertEqual AssertLinter ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server'),
\ ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server'), \ ale#Escape(ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server')) . ' --stdio'
\ ale#handlers#ols#GetExecutable(bufnr(''))
Execute(The gloabl executable should always be used when use_global is set): Execute(The gloabl executable should always be used when use_global is set):
let g:ale_ocaml_ols_use_global = 1 let g:ale_ocaml_ols_use_global = 1
call ale#test#SetFilename('ols_paths/file.ml') call ale#test#SetFilename('ols_paths/file.ml')
AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr('')) AssertLinter 'ocaml-language-server',
\ ale#Escape('ocaml-language-server') . ' --stdio'
Execute(The executable should be configurable): Execute(The executable should be configurable):
let g:ale_ocaml_ols_executable = 'foobar' let g:ale_ocaml_ols_executable = 'foobar'
AssertEqual 'foobar', ale#handlers#ols#GetExecutable(bufnr('')) AssertLinter 'foobar', ale#Escape('foobar') . ' --stdio'

View File

@ -1,37 +1,14 @@
Before: Before:
Save g:ale_perl_perl_executable call ale#assert#SetUpLinterTest('perl', 'perl')
Save g:ale_perl_perl_options
unlet! g:ale_perl_perl_executable
unlet! g:ale_perl_perl_options
runtime ale_linters/perl/perl.vim
After: After:
Restore call ale#assert#TearDownLinterTest()
unlet! b:ale_perl_perl_executable
unlet! b:ale_perl_perl_options
call ale#linter#Reset()
Execute(The default Perl command callback should be correct): Execute(The default Perl command callback should be correct):
AssertEqual AssertLinter 'perl', ale#Escape('perl') . ' -c -Mwarnings -Ilib %t'
\ 'perl',
\ ale_linters#perl#perl#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('perl') . ' -c -Mwarnings -Ilib %t',
\ ale_linters#perl#perl#GetCommand(bufnr(''))
Execute(Overriding the executable and command should work): Execute(Overriding the executable and command should work):
let b:ale_perl_perl_executable = 'foobar' let b:ale_perl_perl_executable = 'foobar'
let b:ale_perl_perl_options = '-w' let b:ale_perl_perl_options = '-w'
AssertEqual AssertLinter 'foobar', ale#Escape('foobar') . ' -w %t'
\ 'foobar',
\ ale_linters#perl#perl#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('foobar') . ' -w %t',
\ ale_linters#perl#perl#GetCommand(bufnr(''))

View File

@ -1,67 +1,36 @@
Before: Before:
Save g:ale_perl_perlcritic_profile call ale#assert#SetUpLinterTest('perl', 'perlcritic')
Save g:ale_perl_perlcritic_options call ale#test#SetFilename('test.pl')
Save g:ale_perl_perlcritic_executable
Save g:ale_perl_perlcritic_showrules
unlet! g:ale_perl_perlcritic_options
unlet! g:ale_perl_perlcritic_executable
unlet! g:ale_perl_perlcritic_showrules
let g:ale_perl_perlcritic_profile = '' let g:ale_perl_perlcritic_profile = ''
runtime ale_linters/perl/perlcritic.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('test.pl')
After: After:
Restore
unlet! b:ale_perl_perlcritic_profile
unlet! b:ale_perl_perlcritic_options
unlet! b:ale_perl_perlcritic_executable
unlet! b:ale_perl_perlcritic_showrules
unlet! b:readme_path unlet! b:readme_path
call ale#assert#TearDownLinterTest()
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The command should be correct with g:ale_perl_perlcritic_showrules off): Execute(The command should be correct with g:ale_perl_perlcritic_showrules off):
let b:ale_perl_perlcritic_showrules = 0 let b:ale_perl_perlcritic_showrules = 0
AssertEqual AssertLinter 'perlcritic', ale#Escape('perlcritic')
\ ale#Escape('perlcritic') \ . ' --verbose ' . ale#Escape('%l:%c %m\n') . ' --nocolor'
\ . ' --verbose ' . ale#Escape('%l:%c %m\n')
\ . ' --nocolor',
\ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
Execute(The command should be correct with g:ale_perl_perlcritic_showrules on): Execute(The command should be correct with g:ale_perl_perlcritic_showrules on):
let b:ale_perl_perlcritic_showrules = 1 let b:ale_perl_perlcritic_showrules = 1
AssertEqual AssertLinter 'perlcritic', ale#Escape('perlcritic')
\ ale#Escape('perlcritic') \ . ' --verbose ' . ale#Escape('%l:%c %m [%p]\n') . ' --nocolor'
\ . ' --verbose ' . ale#Escape('%l:%c %m [%p]\n')
\ . ' --nocolor',
\ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
Execute(The command search for the profile file when set): Execute(The command search for the profile file when set):
let b:ale_perl_perlcritic_profile = 'README.md' let b:ale_perl_perlcritic_profile = 'README.md'
let b:readme_path = ale#path#Simplify(expand('%:p:h:h:h') . '/README.md') let b:readme_path = ale#path#Simplify(expand('%:p:h:h:h') . '/README.md')
AssertEqual AssertLinter 'perlcritic', ale#Escape('perlcritic')
\ ale#Escape('perlcritic') \ . ' --verbose ' . ale#Escape('%l:%c %m\n') . ' --nocolor'
\ . ' --verbose ' . ale#Escape('%l:%c %m\n') \ . ' --profile ' . ale#Escape(b:readme_path)
\ . ' --nocolor'
\ . ' --profile ' . ale#Escape(b:readme_path),
\ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
Execute(Extra options should be set appropriately): Execute(Extra options should be set appropriately):
let b:ale_perl_perlcritic_options = 'beep boop' let b:ale_perl_perlcritic_options = 'beep boop'
AssertEqual AssertLinter 'perlcritic', ale#Escape('perlcritic')
\ ale#Escape('perlcritic') \ . ' --verbose ' . ale#Escape('%l:%c %m\n') . ' --nocolor'
\ . ' --verbose ' . ale#Escape('%l:%c %m\n') \ . ' beep boop'
\ . ' --nocolor'
\ . ' beep boop',
\ ale_linters#perl#perlcritic#GetCommand(bufnr(''))

View File

@ -1,49 +1,29 @@
Before: Before:
Save g:ale_php_langserver_executable call ale#assert#SetUpLinterTest('php', 'langserver')
Save g:ale_php_langserver_config_path
Save g:ale_php_langserver_use_global
unlet! g:ale_php_langserver_executable
unlet! g:ale_php_langserver_config_path
unlet! g:ale_php_langserver_use_global
runtime ale_linters/php/langserver.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After: After:
Restore
if isdirectory(g:dir . '/.git') if isdirectory(g:dir . '/.git')
call delete(g:dir . '/.git', 'd') call delete(g:dir . '/.git', 'd')
endif endif
call ale#test#RestoreDirectory() call ale#assert#TearDownLinterTest()
call ale#linter#Reset()
Execute(The default executable path should be correct): Execute(The default executable path should be correct):
AssertEqual AssertLinter 'php-language-server.php',
\ 'php-language-server.php', \ 'php ' . ale#Escape('php-language-server.php')
\ ale_linters#php#langserver#GetExecutable(bufnr(''))
AssertEqual
\ 'php ' . ale#Escape('php-language-server.php'),
\ ale_linters#php#langserver#GetCommand(bufnr(''))
Execute(Vendor executables should be detected): Execute(Vendor executables should be detected):
call ale#test#SetFilename('php-langserver-project/test.php') call ale#test#SetFilename('php-langserver-project/test.php')
AssertEqual AssertLinter
\ ale#path#Simplify(g:dir . '/php-langserver-project/vendor/bin/php-language-server.php'), \ ale#path#Simplify(g:dir . '/php-langserver-project/vendor/bin/php-language-server.php'),
\ ale_linters#php#langserver#GetExecutable(bufnr(''))
AssertEqual
\ 'php ' . ale#Escape(ale#path#Simplify( \ 'php ' . ale#Escape(ale#path#Simplify(
\ g:dir \ g:dir
\ . '/php-langserver-project/vendor/bin/php-language-server.php' \ . '/php-langserver-project/vendor/bin/php-language-server.php'
\ )), \ ))
\ ale_linters#php#langserver#GetCommand(bufnr(''))
Execute(The project path should be correct for .git directories): Execute(The project path should be correct for .git directories):
call ale#test#SetFilename('php-langserver-project/test.php') call ale#test#SetFilename('php-langserver-project/test.php')
call mkdir(g:dir . '/.git') call mkdir(g:dir . '/.git')
AssertEqual g:dir, ale_linters#php#langserver#GetProjectRoot(bufnr('')) AssertLSPProject g:dir

Some files were not shown because too many files have changed in this diff Show More