summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_brakeman_command_callback.vader4
-rw-r--r--test/command_callback/test_c_clang_tidy_command_callback.vader21
-rw-r--r--test/command_callback/test_c_cppcheck_command_callbacks.vader2
-rw-r--r--test/command_callback/test_clang_tidy_command_callback.vader16
-rw-r--r--test/command_callback/test_cpp_cppcheck_command_callbacks.vader2
-rw-r--r--test/command_callback/test_cs_mcsc_command_callbacks.vader103
-rw-r--r--test/command_callback/test_cuda_nvcc_command_callbacks.vader6
-rw-r--r--test/command_callback/test_erlang_syntaxerl_command_callback.vader24
-rw-r--r--test/command_callback/test_flake8_command_callback.vader56
-rw-r--r--test/command_callback/test_fusionlint_command_callback.vader20
-rw-r--r--test/command_callback/test_javac_command_callback.vader170
-rw-r--r--test/command_callback/test_jscs_command_callback.vader16
-rw-r--r--test/command_callback/test_llc_command_callback.vader39
-rw-r--r--test/command_callback/test_luacheck_command_callback.vader6
-rw-r--r--test/command_callback/test_mypy_command_callback.vader46
-rw-r--r--test/command_callback/test_php_langserver_callbacks.vader6
-rw-r--r--test/command_callback/test_puglint_command_callback.vader22
-rw-r--r--test/command_callback/test_pycodestyle_command_callback.vader8
-rw-r--r--test/command_callback/test_pylint_command_callback.vader37
-rw-r--r--test/fixers/test_prettier_fixer_callback.vader14
-rw-r--r--test/fixers/test_trim_whitespace.vader28
-rw-r--r--test/fixers/test_tslint_fixer_callback.vader41
-rw-r--r--test/handler/test_llc_handler.vader56
-rw-r--r--test/handler/test_lua_handler.vader26
-rw-r--r--test/handler/test_remark_lint_handler.vader27
-rw-r--r--test/handler/test_scalastyle_handler.vader21
-rw-r--r--test/sign/test_sign_limits.vader57
-rw-r--r--test/test_autocmd_commands.vader (renamed from test/test_ale_init_au_groups.vader)6
-rw-r--r--test/test_lint_error_delay.vader4
-rw-r--r--test/test_no_linting_on_write_quit.vader97
-rw-r--r--test/test_python_virtualenv.vader12
-rw-r--r--test/test_quitting_variable.vader39
-rw-r--r--test/test_should_do_nothing_conditions.vader15
33 files changed, 806 insertions, 241 deletions
diff --git a/test/command_callback/test_brakeman_command_callback.vader b/test/command_callback/test_brakeman_command_callback.vader
index b97c5809..f98801b3 100644
--- a/test/command_callback/test_brakeman_command_callback.vader
+++ b/test/command_callback/test_brakeman_command_callback.vader
@@ -25,7 +25,7 @@ Execute(The brakeman command callback should find a valid Rails app root):
AssertEqual
\ 'brakeman -f json -q -p '
- \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')),
+ \ . ale#Escape(ale#path#Winify(g:dir . '/../ruby_fixtures/valid_rails_app')),
\ ale_linters#ruby#brakeman#GetCommand(bufnr(''))
Execute(The brakeman command callback should include configured options):
@@ -35,5 +35,5 @@ Execute(The brakeman command callback should include configured options):
AssertEqual
\ 'brakeman -f json -q --combobulate -p '
- \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')),
+ \ . ale#Escape(ale#path#Winify(g:dir . '/../ruby_fixtures/valid_rails_app')),
\ ale_linters#ruby#brakeman#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_c_clang_tidy_command_callback.vader b/test/command_callback/test_c_clang_tidy_command_callback.vader
index 722a14f1..6f75d777 100644
--- a/test/command_callback/test_c_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_c_clang_tidy_command_callback.vader
@@ -26,7 +26,7 @@ After:
Execute(The clangtidy command default should be correct):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s',
+ \ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to remove the -checks option for clang-tidy):
@@ -42,7 +42,7 @@ Execute(You should be able to set other checks for clang-tidy):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''-*,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):
@@ -50,7 +50,8 @@ Execute(You should be able to manually set compiler flags for clang-tidy):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -- -Wall',
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -- -Wall',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
\
Execute(The build directory should be configurable):
@@ -58,7 +59,8 @@ Execute(The build directory should be configurable):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -p ' . ale#Escape('/foo/bar'),
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -p ' . ale#Escape('/foo/bar'),
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(The build directory setting should override the options):
@@ -67,7 +69,8 @@ Execute(The build directory setting should override the options):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -p ' . ale#Escape('/foo/bar'),
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -p ' . ale#Escape('/foo/bar'),
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(The build directory should be ignored for header files):
@@ -78,14 +81,16 @@ Execute(The build directory should be ignored for header files):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -- -Wall',
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -- -Wall',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
\
call ale#test#SetFilename('test.h')
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -- -Wall',
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -- -Wall',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
Execute(The executable should be configurable):
@@ -93,5 +98,5 @@ Execute(The executable should be configurable):
AssertEqual
\ ale#Escape('foobar')
- \ . ' -checks=''*'' %s',
+ \ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#c#clangtidy#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_c_cppcheck_command_callbacks.vader b/test/command_callback/test_c_cppcheck_command_callbacks.vader
index daf61fbd..e6fe1b7d 100644
--- a/test/command_callback/test_c_cppcheck_command_callbacks.vader
+++ b/test/command_callback/test_c_cppcheck_command_callbacks.vader
@@ -43,7 +43,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files):
call ale#test#SetFilename('cppcheck_paths/one/foo.cpp')
AssertEqual
- \ 'cd ' . ale#Escape(g:dir . '/cppcheck_paths/one') . ' && '
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/cppcheck_paths/one')) . ' && '
\ . ale#Escape('cppcheck')
\ . ' -q --language=c --project=compile_commands.json --enable=style %t',
\ ale_linters#c#cppcheck#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader
index f9e5781c..f82efffe 100644
--- a/test/command_callback/test_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_clang_tidy_command_callback.vader
@@ -26,7 +26,7 @@ After:
Execute(The clangtidy command default should be correct):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s',
+ \ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(You should be able to remove the -checks option for clang-tidy):
@@ -42,7 +42,7 @@ Execute(You should be able to set other checks for clang-tidy):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''-*,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):
@@ -50,7 +50,7 @@ Execute(You should be able to manually set compiler flags for clang-tidy):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -- -Wall',
+ \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
\
Execute(The build directory should be configurable):
@@ -58,7 +58,7 @@ Execute(The build directory should be configurable):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %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):
@@ -67,7 +67,7 @@ Execute(The build directory setting should override the options):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %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):
@@ -78,14 +78,14 @@ Execute(The build directory should be ignored for header files):
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -- -Wall',
+ \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
\
call ale#test#SetFilename('test.hpp')
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s -- -Wall',
+ \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(The executable should be configurable):
@@ -93,5 +93,5 @@ Execute(The executable should be configurable):
AssertEqual
\ ale#Escape('foobar')
- \ . ' -checks=''*'' %s',
+ \ . ' -checks=' . ale#Escape('*') . ' %s',
\ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader
index 18391184..f7b37d4f 100644
--- a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader
+++ b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader
@@ -43,7 +43,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files):
call ale#test#SetFilename('cppcheck_paths/one/foo.cpp')
AssertEqual
- \ 'cd ' . ale#Escape(g:dir . '/cppcheck_paths/one') . ' && '
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/cppcheck_paths/one')) . ' && '
\ . ale#Escape('cppcheck')
\ . ' -q --language=c++ --project=compile_commands.json --enable=style %t',
\ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_cs_mcsc_command_callbacks.vader b/test/command_callback/test_cs_mcsc_command_callbacks.vader
index b513b655..441cef53 100644
--- a/test/command_callback/test_cs_mcsc_command_callbacks.vader
+++ b/test/command_callback/test_cs_mcsc_command_callbacks.vader
@@ -3,118 +3,77 @@ Before:
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:temppath = fnamemodify(tempname(), ':p:h')
- let g:temppathpattern = substitute(escape(g:temppath, '\\/.*$^~[]'), '[\\/]*$', '[\\\\/]\\+\\S\\+','')
- let g:sometempfile = fnamemodify(g:temppath .'/some_temp_file.tmp', ':p')
+ 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:
Restore
+
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:temppath
- unlet! g:temppathpattern
- unlet! g:sometempfile
- call ale#linter#Reset()
-Execute(Check for proper default command):
+ delfunction GetCommand
- let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
- let b:command = substitute(b:command, '\s\+', ' ', 'g')
+ call ale#linter#Reset()
+Execute(Check for proper default command):
AssertEqual
- \ b:command,
- \ 'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
+ \ 'cd ".";mcs -unsafe -out:TEMP -t:module -recurse:"*.cs"',
+ \ GetCommand()
Execute(The options should be be used in the command):
-
let g:ale_cs_mcsc_options = '-pkg:dotnet'
- let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
- let b:command = substitute(b:command, '\s\+', ' ', 'g')
-
AssertEqual
- \ b:command,
- \ 'cd ".";mcs -unsafe ' . g:ale_cs_mcsc_options . ' -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
+ \ 'cd ".";mcs -unsafe ' . g:ale_cs_mcsc_options . ' -out:TEMP -t:module -recurse:"*.cs"',
+ \ GetCommand()
Execute(The souce path should be be used in the command):
- call ale#engine#Cleanup(bufnr(''))
- call ale#engine#InitBufferInfo(bufnr(''))
-
let g:ale_cs_mcsc_source='../foo/bar'
- let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
- let b:command = substitute(b:command, '\s\+', ' ', 'g')
-
AssertEqual
- \ b:command,
- \ 'cd "' . g:ale_cs_mcsc_source . '";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
+ \ 'cd "' . g:ale_cs_mcsc_source . '";mcs -unsafe -out:TEMP -t:module -recurse:"*.cs"',
+ \ GetCommand()
Execute(The list of search pathes for assemblies should be be used in the command if not empty):
- call ale#engine#Cleanup(bufnr(''))
- call ale#engine#InitBufferInfo(bufnr(''))
-
- let g:ale_cs_mcsc_assembly_path = [
- \ '/usr/lib/mono',
- \ '../foo/bar'
- \]
-
- let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
- let b:command = substitute(b:command, '\s\+', ' ', 'g')
+ let g:ale_cs_mcsc_assembly_path = ['/usr/lib/mono', '../foo/bar']
AssertEqual
- \ b:command,
- \ 'cd ".";mcs -unsafe -lib:"' . join(g:ale_cs_mcsc_assembly_path,'","') . '" -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
-
- let g:ale_cs_mcsc_assembly_path = [
- \]
+ \ 'cd ".";mcs -unsafe -lib:"' . join(g:ale_cs_mcsc_assembly_path,'","') . '" -out:TEMP -t:module -recurse:"*.cs"',
+ \ GetCommand()
- let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
- let b:command = substitute(b:command, '\s\+', ' ', 'g')
+ let g:ale_cs_mcsc_assembly_path = []
AssertEqual
- \ b:command,
- \ 'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
+ \ 'cd ".";mcs -unsafe -out:TEMP -t:module -recurse:"*.cs"',
+ \ GetCommand()
Execute(The list of assemblies should be be used in the command if not empty):
- call ale#engine#Cleanup(bufnr(''))
- call ale#engine#InitBufferInfo(bufnr(''))
-
- let g:ale_cs_mcsc_assemblies = [
- \ 'foo.dll',
- \ 'bar.dll'
- \]
-
- let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
- let b:command = substitute(b:command,'\s\+',' ','g')
+ let g:ale_cs_mcsc_assemblies = ['foo.dll', 'bar.dll']
AssertEqual
- \ b:command,
- \ 'cd ".";mcs -unsafe -r:"' . join(g:ale_cs_mcsc_assemblies,'","') . '" -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
+ \ 'cd ".";mcs -unsafe -r:"' . join(g:ale_cs_mcsc_assemblies,'","') . '" -out:TEMP -t:module -recurse:"*.cs"',
+ \ GetCommand()
- let g:ale_cs_mcsc_assemblies = [
- \]
-
- let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
- let b:command = substitute(b:command,'\s\+',' ','g')
+ let g:ale_cs_mcsc_assemblies = []
AssertEqual
- \ b:command,
- \ 'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
-
+ \ 'cd ".";mcs -unsafe -out:TEMP -t:module -recurse:"*.cs"',
+ \ GetCommand()
diff --git a/test/command_callback/test_cuda_nvcc_command_callbacks.vader b/test/command_callback/test_cuda_nvcc_command_callbacks.vader
index 88123e5d..af199d37 100644
--- a/test/command_callback/test_cuda_nvcc_command_callbacks.vader
+++ b/test/command_callback/test_cuda_nvcc_command_callbacks.vader
@@ -24,11 +24,13 @@ Execute(The executable should be configurable):
Execute(The executable should be used in the command):
AssertEqual
- \ ale#Escape('nvcc') . ' -cuda -std=c++11 %s -o /dev/null',
+ \ 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 /dev/null',
+ \ ale#Escape('foobar') . ' -cuda -std=c++11 %s'
+ \ . ' -o ' . g:ale#util#nul_file,
\ ale_linters#cuda#nvcc#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_erlang_syntaxerl_command_callback.vader b/test/command_callback/test_erlang_syntaxerl_command_callback.vader
index 1df2be39..a9a1a500 100644
--- a/test/command_callback/test_erlang_syntaxerl_command_callback.vader
+++ b/test/command_callback/test_erlang_syntaxerl_command_callback.vader
@@ -6,13 +6,11 @@ Before:
runtime ale_linters/erlang/syntaxerl.vim
-
After:
Restore
call ale#linter#Reset()
-
Execute (The executable should be correct):
AssertEqual 'syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr(''))
@@ -25,22 +23,32 @@ Execute (The executable should be correct):
Execute (The executable should be presented in the feature check command):
let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
- AssertEqual "'/some/other/syntaxerl' -h", ale_linters#erlang#syntaxerl#FeatureCheck(bufnr(''))
+
+ AssertEqual
+ \ ale#Escape('/some/other/syntaxerl') . ' -h',
+ \ ale_linters#erlang#syntaxerl#FeatureCheck(bufnr(''))
let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
- AssertEqual "'/yet/another/syntaxerl' -h", ale_linters#erlang#syntaxerl#FeatureCheck(bufnr(''))
+ 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 "'/some/other/syntaxerl' %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
+
+ AssertEqual
+ \ ale#Escape('/some/other/syntaxerl') . ' %t',
+ \ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
- AssertEqual "'/yet/another/syntaxerl' %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
+ AssertEqual
+ \ ale#Escape('/yet/another/syntaxerl') . ' %t',
+ \ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
Execute (The -b option should be used when available):
- AssertEqual "'syntaxerl' %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [
+ AssertEqual ale#Escape('syntaxerl') . ' %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [
\ 'Syntax checker for Erlang (0.14.0)',
\ 'Usage: syntaxerl [-d | --debug] <FILENAME>',
\ ' syntaxerl <-h | --help>',
@@ -48,7 +56,7 @@ Execute (The -b option should be used when available):
\ ' -h, --help Show this message',
\ ])
- AssertEqual "'syntaxerl' -b %s %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [
+ AssertEqual ale#Escape('syntaxerl') . ' -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [
\ 'Syntax checker for Erlang (0.14.0)',
\ 'Usage: syntaxerl [-b | --base <FILENAME>] [-d | --debug] <FILENAME>',
\ ' syntaxerl <-h | --help>',
diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader
index c564b54f..a510f4c1 100644
--- a/test/command_callback/test_flake8_command_callback.vader
+++ b/test/command_callback/test_flake8_command_callback.vader
@@ -8,6 +8,8 @@ Before:
unlet! g:ale_python_flake8_options
unlet! g:ale_python_flake8_use_global
+ let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
+
runtime ale_linters/python/flake8.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
@@ -16,6 +18,9 @@ After:
unlet! g:ale_python_flake8_args
+ unlet! b:bin_dir
+ unlet! b:executable
+
call ale#test#RestoreDirectory()
call ale#linter#Reset()
call ale_linters#python#flake8#ClearVersionCache()
@@ -25,26 +30,29 @@ Execute(The flake8 callbacks should return the correct default values):
\ 'flake8',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ '''flake8'' --version',
+ \ ale#Escape('flake8') . ' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ '''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'])
" Try with older versions.
call ale_linters#python#flake8#ClearVersionCache()
AssertEqual
- \ '''flake8'' --format=default -',
+ \ ale#Escape('flake8') . ' --format=default -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
Execute(The flake8 command callback should let you set options):
let g:ale_python_flake8_options = '--some-option'
AssertEqual
- \ '''flake8'' --some-option --format=default --stdin-display-name %s -',
+ \ ale#Escape('flake8')
+ \ . ' --some-option --format=default'
+ \ . ' --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.4'])
call ale_linters#python#flake8#ClearVersionCache()
AssertEqual
- \ '''flake8'' --some-option --format=default -',
+ \ ale#Escape('flake8')
+ \ . ' --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):
@@ -54,23 +62,29 @@ Execute(You should be able to set a custom executable and it should be escaped):
\ 'executable with spaces',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ '''executable with spaces'' --version',
+ \ ale#Escape('executable with spaces') . ' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ '''executable with spaces'' --format=default --stdin-display-name %s -',
+ \ ale#Escape('executable with spaces')
+ \ . ' --format=default'
+ \ . ' --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
Execute(The flake8 callbacks should detect virtualenv directories):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
+ let b:executable = ale#path#Winify(
+ \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/flake8'
+ \)
+
AssertEqual
- \ g:dir . '/python_paths/with_virtualenv/env/bin/flake8',
+ \ b:executable,
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ '''' . g:dir . '/python_paths/with_virtualenv/env/bin/flake8'' --version',
+ \ ale#Escape(b:executable) . ' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ '''' . g:dir . '/python_paths/with_virtualenv/env/bin/flake8'''
+ \ ale#Escape(b:executable)
\ . ' --format=default --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
@@ -78,35 +92,35 @@ Execute(The FindProjectRoot should detect the project root directory for namespa
silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_manifest/namespace/foo/bar.py')
AssertEqual
- \ fnameescape(g:dir . '/python_paths/namespace_package_manifest'),
+ \ ale#path#Winify(g:dir . '/python_paths/namespace_package_manifest'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_setup/namespace/foo/bar.py')
AssertEqual
- \ fnameescape(g:dir . '/python_paths/namespace_package_setup'),
+ \ ale#path#Winify(g:dir . '/python_paths/namespace_package_setup'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_pytest/namespace/foo/bar.py')
AssertEqual
- \ fnameescape(g:dir . '/python_paths/namespace_package_pytest'),
+ \ ale#path#Winify(g:dir . '/python_paths/namespace_package_pytest'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_tox/namespace/foo/bar.py')
AssertEqual
- \ fnameescape(g:dir . '/python_paths/namespace_package_tox'),
+ \ ale#path#Winify(g:dir . '/python_paths/namespace_package_tox'),
\ ale#python#FindProjectRoot(bufnr(''))
Execute(The FindProjectRoot should detect the project root directory for non-namespace package):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
AssertEqual
- \ fnameescape(g:dir . '/python_paths/no_virtualenv/subdir'),
+ \ ale#path#Winify(g:dir . '/python_paths/no_virtualenv/subdir'),
\ ale#python#FindProjectRoot(bufnr(''))
" Some users currently run flake8 this way, so we should support it.
@@ -120,10 +134,10 @@ Execute(Using `python -m flake8` should be supported for running flake8):
\ 'python',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ '''python'' -m flake8 --version',
+ \ ale#Escape('python') . ' -m flake8 --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ '''python'' -m flake8 --some-option --format=default -',
+ \ ale#Escape('python') . ' -m flake8 --some-option --format=default -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
call ale_linters#python#flake8#ClearVersionCache()
@@ -135,10 +149,10 @@ Execute(Using `python -m flake8` should be supported for running flake8):
\ 'python',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ '''python'' -m flake8 --version',
+ \ ale#Escape('python') . ' -m flake8 --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ '''python'' -m flake8 --some-option --format=default -',
+ \ ale#Escape('python') . ' -m flake8 --some-option --format=default -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
Execute(Using `python2 -m flake8` should be use with the old args option):
@@ -157,8 +171,8 @@ Execute(Using `python2 -m flake8` should be use with the old args option):
\ 'python2',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ '''python2'' -m flake8 --version',
+ \ ale#Escape('python2') . ' -m flake8 --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ '''python2'' -m flake8 --format=default -',
+ \ ale#Escape('python2') . ' -m flake8 --format=default -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
diff --git a/test/command_callback/test_fusionlint_command_callback.vader b/test/command_callback/test_fusionlint_command_callback.vader
index 5398066c..34a44133 100644
--- a/test/command_callback/test_fusionlint_command_callback.vader
+++ b/test/command_callback/test_fusionlint_command_callback.vader
@@ -1,24 +1,34 @@
Before:
+ Save g:ale_fuse_fusionlint_options
+ 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:
+ Restore
+
call ale#linter#Reset()
- let g:ale_fuse_fusionlint_options = ''
- let g:ale_fuse_fusionlint_executable = 'fusion-lint'
Execute(The fuse fusionlint command callback should return the correct default string):
- AssertEqual '''fusion-lint'' --filename %s -i',
+ AssertEqual 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):
let g:ale_fuse_fusionlint_options = '--example-option argument'
- AssertEqual '''fusion-lint'' --example-option argument --filename %s -i',
+ AssertEqual
+ \ ale#Escape('fusion-lint')
+ \ . ' --example-option argument --filename %s -i',
\ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))
Execute(The fusionlint executable should be configurable):
let g:ale_fuse_fusionlint_executable = 'util/linter.fuse'
AssertEqual 'util/linter.fuse', ale_linters#fuse#fusionlint#GetExecutable(1)
- AssertEqual '''util/linter.fuse'' --filename %s -i',
+ AssertEqual
+ \ ale#Escape('util/linter.fuse')
+ \ . ' --filename %s -i',
\ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))
diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader
index 706839e4..8033e4f6 100644
--- a/test/command_callback/test_javac_command_callback.vader
+++ b/test/command_callback/test_javac_command_callback.vader
@@ -1,97 +1,151 @@
Before:
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+
+ Save g:ale_java_javac_options
+ Save g:ale_java_javac_classpath
+
+ unlet! g:ale_java_javac_options
+ unlet! g:ale_java_javac_classpath
+
+ let g:cp_sep = has('unix') ? ':' : ';'
+
+ function! GetCommand(previous_output) abort
+ let l:command = ale_linters#java#javac#GetCommand(
+ \ bufnr(''),
+ \ a:previous_output
+ \)
+
+ let l:split_command = split(l:command)
+ let l:index = index(l:split_command, '-d')
+
+ let l:split_command[l:index + 1] = 'TEMP'
+
+ return join(l:split_command)
+ endfunction
+
runtime ale_linters/java/javac.vim
call ale#engine#InitBufferInfo(bufnr(''))
- silent! cd /testplugin/test/command_callback
+ call ale#test#SetFilename('dummy.java')
After:
+ call ale#test#RestoreDirectory()
+
+ Restore
+
+ unlet! g:cp_sep
+
+ delfunction GetCommand
+
call ale#linter#Reset()
" We need to clean up the buffer to remove the temporary directories created
" for the command.
call ale#engine#Cleanup(bufnr(''))
- let g:ale_java_javac_options = ''
- let g:ale_java_javac_classpath = ''
Execute(The javac callback should return the correct default value):
- let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
-
- Assert match(b:command, '\v^javac +-Xlint +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
+ AssertEqual 'javac -Xlint -d TEMP %t', GetCommand([])
Execute(The javac callback should use g:ale_java_javac_classpath correctly):
let g:ale_java_javac_classpath = 'foo.jar'
- let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
-
- Assert match(b:command, '\v^javac +-Xlint +-cp ''+foo\.jar'' +-d ''+/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
+ AssertEqual
+ \ 'javac -Xlint'
+ \ . ' -cp ' . ale#Escape('foo.jar')
+ \ . ' -d TEMP %t',
+ \ GetCommand([])
Execute(The javac callback should include discovered classpaths):
- let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \])
-
- Assert match(b:command, '\v^javac +-Xlint +-cp ''+/foo/bar\.jar:/xyz/abc\.jar'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
+ AssertEqual
+ \ 'javac -Xlint -cp '
+ \ . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
+ \ . ' -d TEMP %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):
let g:ale_java_javac_classpath = 'configured.jar'
- let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \])
-
- Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar:configured\.jar'' +-d ''+/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
-
- let g:ale_java_javac_classpath = 'configured.jar:configured2.jar'
-
- let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \])
-
- Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar:configured\.jar:configured2\.jar'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
+ AssertEqual
+ \ 'javac -Xlint -cp '
+ \ . ale#Escape(join(
+ \ [
+ \ '/foo/bar.jar',
+ \ '/xyz/abc.jar',
+ \ 'configured.jar',
+ \ ],
+ \ g:cp_sep
+ \ ))
+ \ . ' -d TEMP %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'
+
+ AssertEqual
+ \ 'javac -Xlint -cp '
+ \ . ale#Escape(join(
+ \ [
+ \ '/foo/bar.jar',
+ \ '/xyz/abc.jar',
+ \ 'configured.jar',
+ \ 'configured2.jar',
+ \ ],
+ \ g:cp_sep
+ \ ))
+ \ . ' -d TEMP %t',
+ \ GetCommand([
+ \ '[DEBUG] Ignore this.',
+ \ '[INFO] Something we should ignore.',
+ \ '/foo/bar.jar',
+ \ '/xyz/abc.jar',
+ \ ])
Execute(The javac callback should detect source directories):
call ale#engine#Cleanup(bufnr(''))
:e! java_paths/src/main/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr(''))
- let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
-
- Assert match(b:command, '\v^javac +-Xlint +-sourcepath ''/.*java_paths/src/main/java/'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
+ AssertEqual
+ \ 'javac -Xlint'
+ \ . ' -sourcepath ' . ale#Escape(
+ \ ale#path#Winify(g:dir . '/java_paths/src/main/java/')
+ \ )
+ \ . ' -d TEMP %t',
+ \ GetCommand([])
Execute(The javac callback should combine detected source directories and classpaths):
call ale#engine#Cleanup(bufnr(''))
- :e! java_paths/src/main/java/com/something/dummy
+ call ale#test#SetFilename('java_paths/src/main/java/com/something/dummy.java')
call ale#engine#InitBufferInfo(bufnr(''))
- let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \])
-
- Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar'' +-sourcepath ''/.*java_paths/src/main/java/'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
+ AssertEqual
+ \ 'javac -Xlint'
+ \ . ' -cp ' . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
+ \ . ' -sourcepath ' . ale#Escape(
+ \ ale#path#Winify(g:dir . '/java_paths/src/main/java/')
+ \ )
+ \ . ' -d TEMP %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):
-
let g:ale_java_javac_options = '--anything --else'
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
- Assert match(b:command, '\v^javac +-Xlint +-d +''/tmp/[0-9a-zA-Z/]+'' --anything --else +\%t$') >= 0,
- \ 'Invalid command string: ' . b:command
+ AssertEqual
+ \ 'javac -Xlint'
+ \ . ' -d TEMP --anything --else %t',
+ \ GetCommand([])
diff --git a/test/command_callback/test_jscs_command_callback.vader b/test/command_callback/test_jscs_command_callback.vader
index 8245337e..f118c039 100644
--- a/test/command_callback/test_jscs_command_callback.vader
+++ b/test/command_callback/test_jscs_command_callback.vader
@@ -7,19 +7,19 @@ After:
Execute(Should return the correct default values):
AssertEqual
- \ 'jscs',
- \ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
+ \ 'jscs',
+ \ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
AssertEqual
- \ '''jscs'' --reporter inline --no-colors -',
- \ ale_linters#javascript#jscs#GetCommand(bufnr(''))
+ \ ale#Escape('jscs') . ' --reporter inline --no-colors -',
+ \ ale_linters#javascript#jscs#GetCommand(bufnr(''))
Execute(Should allow using a custom executable):
let g:ale_javascript_jscs_executable = 'foobar'
AssertEqual
- \ 'foobar',
- \ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
+ \ 'foobar',
+ \ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
AssertEqual
- \ '''foobar'' --reporter inline --no-colors -',
- \ ale_linters#javascript#jscs#GetCommand(bufnr(''))
+ \ ale#Escape('foobar') . ' --reporter inline --no-colors -',
+ \ ale_linters#javascript#jscs#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_llc_command_callback.vader b/test/command_callback/test_llc_command_callback.vader
new file mode 100644
index 00000000..296b277a
--- /dev/null
+++ b/test/command_callback/test_llc_command_callback.vader
@@ -0,0 +1,39 @@
+Before:
+ Save g:ale_llvm_llc_executable
+
+ unlet! g:ale_llvm_llc_executable
+ unlet! b:ale_llvm_llc_executable
+
+ runtime ale_linters/llvm/llc.vim
+
+ function! AssertHasPrefix(str, prefix) abort
+ let msg = printf("'%s' is expected to be prefixed with '%s'", a:str, a:prefix)
+ AssertEqual stridx(a:str, a:prefix), 0, msg
+ endfunction
+
+After:
+ unlet! g:ale_llvm_llc_executable
+ unlet! b:ale_llvm_llc_executable
+ delfunction AssertHasPrefix
+ Restore
+
+Execute(llc command is customizable):
+ let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
+ call AssertHasPrefix(cmd, ale#Escape('llc'))
+
+ 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'
+ let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
+ 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'
diff --git a/test/command_callback/test_luacheck_command_callback.vader b/test/command_callback/test_luacheck_command_callback.vader
index c4ee98a8..6f7f3a00 100644
--- a/test/command_callback/test_luacheck_command_callback.vader
+++ b/test/command_callback/test_luacheck_command_callback.vader
@@ -7,18 +7,18 @@ After:
let g:ale_lua_luacheck_executable = 'luacheck'
Execute(The lua luacheck command callback should return the correct default string):
- AssertEqual '''luacheck'' --formatter plain --codes --filename %s -',
+ AssertEqual ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -',
\ join(split(ale_linters#lua#luacheck#GetCommand(1)))
Execute(The lua luacheck command callback should let you set options):
let g:ale_lua_luacheck_options = '--config filename'
- AssertEqual '''luacheck'' --config filename --formatter plain --codes --filename %s -',
+ AssertEqual ale#Escape('luacheck') . ' --config filename --formatter plain --codes --filename %s -',
\ join(split(ale_linters#lua#luacheck#GetCommand(1)))
Execute(The luacheck executable should be configurable):
let g:ale_lua_luacheck_executable = 'luacheck.sh'
AssertEqual 'luacheck.sh', ale_linters#lua#luacheck#GetExecutable(1)
- AssertEqual '''luacheck.sh'' --formatter plain --codes --filename %s -',
+ AssertEqual ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -',
\ join(split(ale_linters#lua#luacheck#GetCommand(1)))
diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader
index 8df7193d..4ccc008e 100644
--- a/test/command_callback/test_mypy_command_callback.vader
+++ b/test/command_callback/test_mypy_command_callback.vader
@@ -1,20 +1,35 @@
Before:
+ Save g:ale_python_mypy_executable
+ Save g:ale_python_mypy_options
+ 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'
+
runtime ale_linters/python/mypy.vim
+
call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#test#SetFilename('test.py')
After:
+ Restore
+
+ unlet! b:bin_dir
+ unlet! b:executable
+
call ale#test#RestoreDirectory()
call ale#linter#Reset()
- let g:ale_python_mypy_executable = 'mypy'
- let g:ale_python_mypy_options = ''
- let g:ale_python_mypy_use_global = 0
Execute(The mypy callbacks should return the correct default values):
AssertEqual
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers '
+ \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy')
+ \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
@@ -25,7 +40,8 @@ Execute(The mypy executable should be configurable, and escaped properly):
\ 'executable with spaces',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . ''' && ''executable with spaces'' --show-column-numbers '
+ \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('executable with spaces')
+ \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
@@ -33,7 +49,8 @@ Execute(The mypy command callback should let you set options):
let g:ale_python_mypy_options = '--some-option'
AssertEqual
- \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers --some-option '
+ \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy')
+ \ . ' --show-column-numbers --some-option '
\ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
@@ -44,19 +61,24 @@ Execute(The mypy command should switch directories to the detected project root)
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . '/python_paths/no_virtualenv/subdir'' && ''mypy'' --show-column-numbers '
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/python_paths/no_virtualenv/subdir'))
+ \ . ' && ' . ale#Escape('mypy')
+ \ . ' --show-column-numbers '
\ . '--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):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
+ let b:executable = ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/mypy')
+
AssertEqual
- \ g:dir . '/python_paths/with_virtualenv/env/bin/mypy',
+ \ b:executable,
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && '''
- \ . g:dir . '/python_paths/with_virtualenv/env/bin/mypy'' --show-column-numbers '
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/subdir'))
+ \ . ' && ' . ale#Escape(b:executable)
+ \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
@@ -68,6 +90,8 @@ Execute(You should able able to use the global mypy instead):
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && ''mypy'' --show-column-numbers '
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/subdir'))
+ \ . ' && ' . ale#Escape('mypy')
+ \ . ' --show-column-numbers '
\ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_php_langserver_callbacks.vader b/test/command_callback/test_php_langserver_callbacks.vader
index 38630f4b..0c7e69ef 100644
--- a/test/command_callback/test_php_langserver_callbacks.vader
+++ b/test/command_callback/test_php_langserver_callbacks.vader
@@ -33,13 +33,13 @@ Execute(Vendor executables should be detected):
call ale#test#SetFilename('php-langserver-project/test.php')
AssertEqual
- \ g:dir . '/php-langserver-project/vendor/bin/php-language-server.php',
+ \ ale#path#Winify(g:dir . '/php-langserver-project/vendor/bin/php-language-server.php'),
\ ale_linters#php#langserver#GetExecutable(bufnr(''))
AssertEqual
- \ 'php ' . ale#Escape(
+ \ 'php ' . ale#Escape(ale#path#Winify(
\ g:dir
\ . '/php-langserver-project/vendor/bin/php-language-server.php'
- \ ),
+ \ )),
\ ale_linters#php#langserver#GetCommand(bufnr(''))
Execute(The language string should be correct):
diff --git a/test/command_callback/test_puglint_command_callback.vader b/test/command_callback/test_puglint_command_callback.vader
index 6d189899..11946582 100644
--- a/test/command_callback/test_puglint_command_callback.vader
+++ b/test/command_callback/test_puglint_command_callback.vader
@@ -21,11 +21,12 @@ Execute(puglint should detect local executables and package.json):
call ale#test#SetFilename('puglint_project/test.pug')
AssertEqual
- \ g:dir . '/puglint_project/node_modules/.bin/pug-lint',
+ \ ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'),
\ ale_linters#pug#puglint#GetExecutable(bufnr(''))
+
AssertEqual
- \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint')
- \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/package.json')
+ \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
+ \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/package.json'))
\ . ' -r inline %t',
\ ale_linters#pug#puglint#GetCommand(bufnr(''))
@@ -35,9 +36,10 @@ Execute(puglint should use global executables if configured):
call ale#test#SetFilename('puglint_project/test.pug')
AssertEqual 'pug-lint', ale_linters#pug#puglint#GetExecutable(bufnr(''))
+
AssertEqual
\ ale#Escape('pug-lint')
- \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/package.json')
+ \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/package.json'))
\ . ' -r inline %t',
\ ale_linters#pug#puglint#GetCommand(bufnr(''))
@@ -45,8 +47,8 @@ Execute(puglint should detect .pug-lintrc):
call ale#test#SetFilename('puglint_project/puglint_rc_dir/subdir/test.pug')
AssertEqual
- \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint')
- \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/puglint_rc_dir/.pug-lintrc')
+ \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
+ \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/puglint_rc_dir/.pug-lintrc'))
\ . ' -r inline %t',
\ ale_linters#pug#puglint#GetCommand(bufnr(''))
@@ -54,8 +56,8 @@ Execute(puglint should detect .pug-lintrc.js):
call ale#test#SetFilename('puglint_project/puglint_rc_js_dir/subdir/test.pug')
AssertEqual
- \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint')
- \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/puglint_rc_js_dir/.pug-lintrc.js')
+ \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
+ \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/puglint_rc_js_dir/.pug-lintrc.js'))
\ . ' -r inline %t',
\ ale_linters#pug#puglint#GetCommand(bufnr(''))
@@ -63,7 +65,7 @@ Execute(puglint should detect .pug-lintrc.json):
call ale#test#SetFilename('puglint_project/puglint_rc_json_dir/subdir/test.pug')
AssertEqual
- \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint')
- \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/puglint_rc_json_dir/.pug-lintrc.json')
+ \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
+ \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/puglint_rc_json_dir/.pug-lintrc.json'))
\ . ' -r inline %t',
\ ale_linters#pug#puglint#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_pycodestyle_command_callback.vader b/test/command_callback/test_pycodestyle_command_callback.vader
index a5163461..58aefa20 100644
--- a/test/command_callback/test_pycodestyle_command_callback.vader
+++ b/test/command_callback/test_pycodestyle_command_callback.vader
@@ -9,15 +9,17 @@ After:
Restore
Execute(The pycodestyle command callback should return default string):
- AssertEqual '''pycodestyle'' -',
+ AssertEqual ale#Escape('pycodestyle') . ' -',
\ ale_linters#python#pycodestyle#GetCommand(bufnr(''))
Execute(The pycodestyle command callback should allow options):
let g:ale_python_pycodestyle_options = '--exclude=test*.py'
- AssertEqual '''pycodestyle'' --exclude=test*.py -',
+
+ AssertEqual ale#Escape('pycodestyle') . ' --exclude=test*.py -',
\ ale_linters#python#pycodestyle#GetCommand(bufnr(''))
Execute(The pycodestyle executable should be configurable):
let g:ale_python_pycodestyle_executable = '~/.local/bin/pycodestyle'
- AssertEqual '''~/.local/bin/pycodestyle'' -',
+
+ AssertEqual ale#Escape('~/.local/bin/pycodestyle') . ' -',
\ ale_linters#python#pycodestyle#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader
index f8f44ab6..447409b2 100644
--- a/test/command_callback/test_pylint_command_callback.vader
+++ b/test/command_callback/test_pylint_command_callback.vader
@@ -1,22 +1,34 @@
Before:
+ Save g:ale_python_pylint_executable
+ Save g:ale_python_pylint_options
+ Save g:ale_python_pylint_use_global
+
+ unlet! g:ale_python_pylint_executable
+ unlet! g:ale_python_pylint_options
+ unlet! g:ale_python_pylint_use_global
+
runtime ale_linters/python/pylint.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
+ let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
+
let b:command_tail = ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
After:
+ Restore
+
call ale#test#RestoreDirectory()
call ale#linter#Reset()
- let g:ale_python_pylint_executable = 'pylint'
- let g:ale_python_pylint_options = ''
- let g:ale_python_pylint_use_global = 0
+
+ unlet! b:bin_dir
+ unlet! b:executable
Execute(The pylint callbacks should return the correct default values):
AssertEqual
\ 'pylint',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ '''pylint'' ' . b:command_tail,
+ \ ale#Escape('pylint') . ' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint executable should be configurable, and escaped properly):
@@ -26,14 +38,14 @@ Execute(The pylint executable should be configurable, and escaped properly):
\ 'executable with spaces',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ '''executable with spaces'' ' . b:command_tail,
+ \ ale#Escape('executable with spaces') . ' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint command callback should let you set options):
let g:ale_python_pylint_options = '--some-option'
AssertEqual
- \ '''pylint'' --some-option' . b:command_tail,
+ \ ale#Escape('pylint') . ' --some-option' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint callbacks shouldn't detect virtualenv directories where they don't exist):
@@ -43,17 +55,22 @@ Execute(The pylint callbacks shouldn't detect virtualenv directories where they
\ 'pylint',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ '''pylint'' ' . b:command_tail,
+ \ ale#Escape('pylint') . ' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint callbacks should detect virtualenv directories):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
+ let b:executable = ale#path#Winify(
+ \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pylint'
+ \)
+
AssertEqual
- \ g:dir . '/python_paths/with_virtualenv/env/bin/pylint',
+ \ b:executable,
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
+
AssertEqual
- \ ''''. g:dir . '/python_paths/with_virtualenv/env/bin/pylint'' ' . b:command_tail,
+ \ ale#Escape(b:executable) . ' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(You should able able to use the global pylint instead):
@@ -64,5 +81,5 @@ Execute(You should able able to use the global pylint instead):
\ 'pylint',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ '''pylint'' ' . b:command_tail,
+ \ ale#Escape('pylint') . ' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader
index cc7d34d0..471a8632 100644
--- a/test/fixers/test_prettier_fixer_callback.vader
+++ b/test/fixers/test_prettier_fixer_callback.vader
@@ -114,3 +114,17 @@ Execute(Append '--parser postcss' for filetype=css):
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
+
+Execute(Append '--parser postcss' for filetype=less):
+ set filetype=less
+ call ale#test#SetFilename('../prettier-test-files/testfile.less')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
+ \ . ' %t'
+ \ . ' --parser postcss'
+ \ . ' --write',
+ \ },
+ \ ale#fixers#prettier#Fix(bufnr(''))
diff --git a/test/fixers/test_trim_whitespace.vader b/test/fixers/test_trim_whitespace.vader
new file mode 100644
index 00000000..2ffbcb04
--- /dev/null
+++ b/test/fixers/test_trim_whitespace.vader
@@ -0,0 +1,28 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ call ale#test#RestoreDirectory()
+
+Execute(Should delete all whitespace at the end of different lines):
+ AssertEqual
+ \ [
+ \ 'def foo():',
+ \ ' some_variable = this_is_a_longer_function(',
+ \ 'first_argument,',
+ \ ' second_argument,',
+ \ ' third_with_function_call(',
+ \ 'foo,',
+ \ ' bar,',
+ \ '))',
+ \ ],
+ \ ale#fixers#generic#TrimWhitespace(bufnr(''), [
+ \ 'def foo():',
+ \ ' some_variable = this_is_a_longer_function(',
+ \ 'first_argument,',
+ \ ' second_argument,',
+ \ ' third_with_function_call(',
+ \ 'foo,',
+ \ ' bar,',
+ \ '))',
+ \ ])
diff --git a/test/fixers/test_tslint_fixer_callback.vader b/test/fixers/test_tslint_fixer_callback.vader
new file mode 100644
index 00000000..5bfafe24
--- /dev/null
+++ b/test/fixers/test_tslint_fixer_callback.vader
@@ -0,0 +1,41 @@
+Before:
+ Save g:ale_typescript_tslint_executable
+ Save g:ale_typescript_tslint_config_path
+
+ let g:ale_typescript_tslint_executable = 'xxxinvalid'
+ let g:ale_typescript_tslint_config_path = 'tslint.json'
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The tslint callback should return the correct default values):
+ call ale#test#SetFilename('../prettier-test-files/testfile.ts')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_typescript_tslint_executable)
+ \ . ' -c ' . ale#Escape('tslint.json')
+ \ . ' --fix %t',
+ \ },
+ \ ale#fixers#tslint#Fix(bufnr(''))
+
+Execute(The tslint callback should include custom tslint config option):
+ let g:ale_typescript_tslint_config_path = '.tslintrc'
+ call ale#test#SetFilename('../prettier-test-files/testfile.ts')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_typescript_tslint_executable)
+ \ . ' -c ' . ale#Escape(g:ale_typescript_tslint_config_path)
+ \ . ' --fix %t',
+ \ },
+ \ ale#fixers#tslint#Fix(bufnr(''))
diff --git a/test/handler/test_llc_handler.vader b/test/handler/test_llc_handler.vader
new file mode 100644
index 00000000..edea2337
--- /dev/null
+++ b/test/handler/test_llc_handler.vader
@@ -0,0 +1,56 @@
+Before:
+ runtime! ale_linters/llvm/llc.vim
+
+Execute(llc handler should parse errors output for STDIN):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 10,
+ \ 'col': 7,
+ \ 'text': "error: value doesn't match function result type 'i32'",
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 10,
+ \ 'col': 13,
+ \ 'text': "error: use of undefined value '@foo'",
+ \ 'type': 'E',
+ \ },
+ \ ],
+ \ ale_linters#llvm#llc#HandleErrors(bufnr(''), [
+ \ "llc: <stdin>:10:7: error: value doesn't match function result type 'i32'",
+ \ 'ret i64 0',
+ \ ' ^',
+ \ '',
+ \ "llc: <stdin>:10:13: error: use of undefined value '@foo'",
+ \ 'call void @foo(i64 %0)',
+ \ ' ^',
+ \ ])
+
+Execute(llc handler should parse errors output for some file):
+ call ale#test#SetFilename('test.ll')
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 10,
+ \ 'col': 7,
+ \ 'text': "error: value doesn't match function result type 'i32'",
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 10,
+ \ 'col': 13,
+ \ 'text': "error: use of undefined value '@foo'",
+ \ 'type': 'E',
+ \ },
+ \ ],
+ \ ale_linters#llvm#llc#HandleErrors(bufnr(''), [
+ \ "llc: /path/to/test.ll:10:7: error: value doesn't match function result type 'i32'",
+ \ 'ret i64 0',
+ \ ' ^',
+ \ '',
+ \ "llc: /path/to/test.ll:10:13: error: use of undefined value '@foo'",
+ \ 'call void @foo(i64 %0)',
+ \ ' ^',
+ \ ])
+
diff --git a/test/handler/test_lua_handler.vader b/test/handler/test_lua_handler.vader
index af1c134e..712c7c59 100644
--- a/test/handler/test_lua_handler.vader
+++ b/test/handler/test_lua_handler.vader
@@ -1,4 +1,8 @@
+Before:
+ Save g:ale_warn_about_trailing_whitespace
+
After:
+ Restore
call ale#linter#Reset()
Execute(The luacheck handler should parse lines correctly):
@@ -30,3 +34,25 @@ Execute(The luacheck handler should parse lines correctly):
\ ' /file/path/here.lua:3:5: (W213) unused loop variable ''k''',
\ ' /file/path/here.lua:3:19: (W113) accessing undefined variable ''x''',
\ ])
+
+Execute(The luacheck handler should respect the warn_about_trailing_whitespace option):
+ runtime ale_linters/lua/luacheck.vim
+
+ let g:ale_warn_about_trailing_whitespace = 0
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 5,
+ \ 'col': 43,
+ \ 'text': 'W212: unused argument ''g''',
+ \ 'type': 'W',
+ \ }
+ \ ],
+ \ ale_linters#lua#luacheck#Handle(347, [
+ \ '/file/path/here.lua:15:97: (W614) trailing whitespace in a comment',
+ \ '/file/path/here.lua:16:60: (W612) line contains trailing whitespace',
+ \ '/file/path/here.lua:17:1: (W611) line contains only whitespace',
+ \ '/file/path/here.lua:27:57: (W613) trailing whitespace in a string',
+ \ '/file/path/here.lua:5:43: (W212) unused argument ''g''',
+ \ ])
diff --git a/test/handler/test_remark_lint_handler.vader b/test/handler/test_remark_lint_handler.vader
new file mode 100644
index 00000000..f63e0c5b
--- /dev/null
+++ b/test/handler/test_remark_lint_handler.vader
@@ -0,0 +1,27 @@
+Before:
+ runtime ale_linters/markdown/remark_lint.vim
+
+Execute(Warning and error messages should be handled correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 4,
+ \ 'type': 'W',
+ \ 'text': 'Incorrect list-item indent: add 1 space list-item-indent remark-lint',
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 5,
+ \ 'type': 'E',
+ \ 'text': 'Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
+ \ },
+ \ ],
+ \ ale_linters#markdown#remark_lint#Handle(1, [
+ \ 'foo.md',
+ \ ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint',
+ \ ' 3:5 error Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
+ \ '',
+ \ '⚠ 1 warnings',
+ \ '✘ 1 errors',
+ \])
diff --git a/test/handler/test_scalastyle_handler.vader b/test/handler/test_scalastyle_handler.vader
index b03d18e7..32da79c0 100644
--- a/test/handler/test_scalastyle_handler.vader
+++ b/test/handler/test_scalastyle_handler.vader
@@ -1,6 +1,10 @@
-Execute(The scalastyle handler should parse lines correctly):
+Before:
runtime! ale_linters/scala/scalastyle.vim
+After:
+ call ale#linter#Reset()
+
+Execute(The scalastyle handler should parse lines correctly):
AssertEqual
\ [
\ {
@@ -34,5 +38,16 @@ Execute(The scalastyle handler should parse lines correctly):
\ 'Finished in 934 ms',
\ ])
-After:
- call ale#linter#Reset()
+Execute(The scalastyle linter should complain when there is no configuration file):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'text': '(See :help ale-scala-scalastyle) No scalastyle configuration file was found.',
+ \ },
+ \ ],
+ \ ale_linters#scala#scalastyle#Handle(347, [
+ \ 'scalastyle 1.0.0',
+ \ 'Usage: scalastyle [options] <source directory>',
+ \ ' -c, --config FILE configuration file (required)',
+ \ ])
diff --git a/test/sign/test_sign_limits.vader b/test/sign/test_sign_limits.vader
new file mode 100644
index 00000000..b8868aeb
--- /dev/null
+++ b/test/sign/test_sign_limits.vader
@@ -0,0 +1,57 @@
+Before:
+ Save g:ale_max_signs
+
+ let g:ale_max_signs = -1
+
+ function! SetNProblems(sign_count)
+ let l:loclist = []
+ let l:range = range(1, a:sign_count)
+ call setline(1, l:range)
+
+ for l:index in l:range
+ call add(l:loclist, {
+ \ 'bufnr': bufnr(''),
+ \ 'lnum': l:index,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'a',
+ \})
+ endfor
+
+ call ale#sign#SetSigns(bufnr(''), l:loclist)
+
+ return sort(map(ale#sign#FindCurrentSigns(bufnr(''))[1], 'v:val[0]'), 'n')
+ endfunction
+
+After:
+ Restore
+
+ unlet! b:ale_max_signs
+
+ delfunction SetNProblems
+
+ sign unplace *
+
+Execute(There should be no limit on signs with negative numbers):
+ AssertEqual range(1, 42), SetNProblems(42)
+
+Execute(0 signs should be set when the max is 0):
+ let g:ale_max_signs = 0
+
+ AssertEqual [], SetNProblems(42)
+
+Execute(1 signs should be set when the max is 1):
+ let g:ale_max_signs = 1
+
+ AssertEqual [1], SetNProblems(42)
+
+Execute(10 signs should be set when the max is 10):
+ let g:ale_max_signs = 10
+
+ " We'll check that we set signs for the first 10 items, not other lines.
+ AssertEqual range(1, 10), SetNProblems(42)
+
+Execute(5 signs should be set when the max is 5 for the buffer):
+ let b:ale_max_signs = 5
+
+ AssertEqual range(1, 5), SetNProblems(42)
diff --git a/test/test_ale_init_au_groups.vader b/test/test_autocmd_commands.vader
index 2685f50b..17e3b16d 100644
--- a/test/test_ale_init_au_groups.vader
+++ b/test/test_autocmd_commands.vader
@@ -199,6 +199,12 @@ Execute (g:ale_echo_cursor = 1 should bind cursor events):
\ 'InsertLeave * call ale#cursor#EchoCursorWarning()',
\], CheckAutocmd('ALECursorGroup')
+Execute (ALECleanupGroup should include the right commands):
+ AssertEqual [
+ \ 'BufUnload * call ale#engine#Cleanup(str2nr(expand(''<abuf>'')))',
+ \ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
+ \], CheckAutocmd('ALECleanupGroup')
+
Execute(Enabling completion should set up autocmd events correctly):
let g:ale_completion_enabled = 0
call ale#completion#Enable()
diff --git a/test/test_lint_error_delay.vader b/test/test_lint_error_delay.vader
index 4c7f0947..7f081794 100644
--- a/test/test_lint_error_delay.vader
+++ b/test/test_lint_error_delay.vader
@@ -17,10 +17,6 @@ Execute(ALE should stop linting for a while after exceptions are thrown):
AssertThrows call ale#Lint()
call ale#Lint()
-Execute(ALE should stop queuing echo messages for a while after exceptions are thrown):
- AssertThrows call ale#cursor#EchoCursorWarningWithDelay()
- call ale#cursor#EchoCursorWarningWithDelay()
-
Execute(ALE should stop echoing messages for a while after exceptions are thrown):
AssertThrows call ale#cursor#EchoCursorWarning()
call ale#cursor#EchoCursorWarning()
diff --git a/test/test_no_linting_on_write_quit.vader b/test/test_no_linting_on_write_quit.vader
new file mode 100644
index 00000000..d3baeaa1
--- /dev/null
+++ b/test/test_no_linting_on_write_quit.vader
@@ -0,0 +1,97 @@
+Before:
+ Save g:ale_echo_cursor
+ Save g:ale_fix_on_save
+ Save g:ale_fixers
+ Save g:ale_lint_on_save
+
+ let g:ale_echo_cursor = 0
+ let g:ale_run_synchronously = 1
+
+ function! TestCallback(buffer, output)
+ return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
+ endfunction
+
+ function AddLine(buffer, lines) abort
+ return a:lines + ['x']
+ endfunction
+
+ let g:ale_fixers = {
+ \ 'testft': ['AddLine'],
+ \}
+
+ call ale#linter#Define('testft', {
+ \ 'name': 'testlinter',
+ \ 'callback': 'TestCallback',
+ \ 'executable': has('win32') ? 'cmd' : 'true',
+ \ 'command': 'true',
+ \})
+
+Given testft (An empty file):
+
+After:
+ Restore
+
+ unlet! g:ale_run_synchronously
+ unlet! b:ale_quitting
+ delfunction TestCallback
+ delfunction AddLine
+
+ call ale#linter#Reset()
+ call setloclist(0, [])
+
+Execute(No linting should be done on :wq or :x):
+ let g:ale_lint_on_save = 1
+ let g:ale_fix_on_save = 0
+
+ " First try just the SaveEvent, to be sure that we set errors in the test.
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual 1, len(getloclist(0))
+
+ " Now try doing it again, but where we run the quit event first.
+ call setloclist(0, [])
+ call ale#events#QuitEvent(bufnr(''))
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual [], getloclist(0)
+
+Execute(No linting should be for :w after :q fails):
+ let g:ale_lint_on_save = 1
+ let g:ale_fix_on_save = 0
+
+ call ale#events#QuitEvent(bufnr(''))
+
+ " Simulate 2 seconds passing.
+ let b:ale_quitting -= 1000
+
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual 1, len(getloclist(0))
+
+Execute(No linting should be done on :wq or :x after fixing files):
+ let g:ale_lint_on_save = 0
+ let g:ale_fix_on_save = 1
+
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual 1, len(getloclist(0))
+
+ " Now try doing it again, but where we run the quit event first.
+ call setloclist(0, [])
+ call ale#events#QuitEvent(bufnr(''))
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual [], getloclist(0)
+
+Execute(Linting should be done after :q fails and fixing files):
+ let g:ale_lint_on_save = 0
+ let g:ale_fix_on_save = 1
+
+ call ale#events#QuitEvent(bufnr(''))
+
+ " Simulate 2 seconds passing.
+ let b:ale_quitting -= 1000
+
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual 1, len(getloclist(0))
diff --git a/test/test_python_virtualenv.vader b/test/test_python_virtualenv.vader
new file mode 100644
index 00000000..b44c5fa2
--- /dev/null
+++ b/test/test_python_virtualenv.vader
@@ -0,0 +1,12 @@
+Before:
+ Save $VIRTUAL_ENV
+ let $VIRTUAL_ENV = "/opt/example/"
+
+After:
+ Restore
+
+Execute(ale#python#FindVirtualenv falls back to $VIRTUAL_ENV when no directories match):
+ AssertEqual
+ \ ale#python#FindVirtualenv(bufnr('%')),
+ \ '/opt/example/',
+ \ 'Expected VIRTUAL_ENV environment variable to be used, but it was not'
diff --git a/test/test_quitting_variable.vader b/test/test_quitting_variable.vader
new file mode 100644
index 00000000..bef344a8
--- /dev/null
+++ b/test/test_quitting_variable.vader
@@ -0,0 +1,39 @@
+Before:
+ Save g:ale_enabled
+
+ unlet! b:ale_quitting
+ let g:ale_enabled = 0
+
+After:
+ Restore
+
+ unlet! b:ale_quitting
+ unlet! b:time_before
+
+Execute(QuitEvent should set b:ale_quitting some time from the clock):
+ let b:time_before = ale#util#ClockMilliseconds()
+
+ call ale#events#QuitEvent(bufnr(''))
+
+ Assert b:ale_quitting >= b:time_before
+ Assert b:ale_quitting <= ale#util#ClockMilliseconds()
+
+Execute(EnterEvent should set b:ale_quitting to 0):
+ let b:ale_quitting = 1
+
+ call ale#events#EnterEvent(bufnr(''))
+
+ AssertEqual 0, b:ale_quitting
+
+Execute(The QuitRecently function should work when the variable isn't set):
+ AssertEqual 0, ale#events#QuitRecently(bufnr(''))
+
+Execute(The QuitRecently function should return 1 when ALE quit recently):
+ let b:ale_quitting = ale#util#ClockMilliseconds()
+
+ AssertEqual 1, ale#events#QuitRecently(bufnr(''))
+
+Execute(The QuitRecently function should return 0 when a second has passed):
+ let b:ale_quitting = ale#util#ClockMilliseconds() - 1001
+
+ AssertEqual 0, ale#events#QuitRecently(bufnr(''))
diff --git a/test/test_should_do_nothing_conditions.vader b/test/test_should_do_nothing_conditions.vader
index 4d6facf9..3afa11ac 100644
--- a/test/test_should_do_nothing_conditions.vader
+++ b/test/test_should_do_nothing_conditions.vader
@@ -1,7 +1,22 @@
Before:
Save &l:statusline
+ let b:funky_command_created = 0
+
+ " We will test for the existence of this command, so create one if needed.
+ if !exists(':CtrlPFunky')
+ command CtrlPFunky echo
+ let b:funky_command_created = 1
+ endif
+
After:
+ if b:funky_command_created
+ delcommand CtrlPFunky
+ let b:funky_command_created = 0
+ endif
+
+ unlet! b:funky_command_created
+
Restore
Execute(ALE shouldn't do much of anything for ctrlp-funky buffers):