summaryrefslogtreecommitdiff
path: root/test/command_callback
diff options
context:
space:
mode:
Diffstat (limited to 'test/command_callback')
-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
19 files changed, 370 insertions, 234 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(''))