diff options
Diffstat (limited to 'test')
35 files changed, 577 insertions, 401 deletions
diff --git a/test/hack_files/testfile.php b/test/command_callback/cquery_paths/with_compile_commands_json/compile_commands.json index e69de29b..e69de29b 100644 --- a/test/hack_files/testfile.php +++ b/test/command_callback/cquery_paths/with_compile_commands_json/compile_commands.json diff --git a/test/command_callback/cquery_paths/with_cquery/.cquery b/test/command_callback/cquery_paths/with_cquery/.cquery new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/cquery_paths/with_cquery/.cquery diff --git a/test/command_callback/test_c_cquery_command_callbacks.vader b/test/command_callback/test_c_cquery_command_callbacks.vader new file mode 100644 index 00000000..13b7a567 --- /dev/null +++ b/test/command_callback/test_c_cquery_command_callbacks.vader @@ -0,0 +1,33 @@ +Before: + call ale#assert#SetUpLinterTest('c', 'cquery') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('cquery_paths/with_compile_commands_json/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .cquery file): + AssertLSPProject '' + + call ale#test#SetFilename('cquery_paths/with_cquery/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_cquery') + +Execute(The executable should be configurable): + AssertLinter 'cquery', ale#Escape('cquery') + + let b:ale_c_cquery_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(The cache directory should be configurable): + AssertLSPOptions {'cacheDirectory': expand('$HOME/.cache/cquery')} + + let b:ale_c_cquery_cache_directory = '/foo/bar' + + AssertLSPOptions {'cacheDirectory': '/foo/bar'} diff --git a/test/command_callback/test_c_flawfinder_command_callbacks.vader b/test/command_callback/test_c_flawfinder_command_callbacks.vader index 44573ff5..38385e2b 100644 --- a/test/command_callback/test_c_flawfinder_command_callbacks.vader +++ b/test/command_callback/test_c_flawfinder_command_callbacks.vader @@ -13,7 +13,7 @@ Execute(The minlevel of flawfinder should be configurable): AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t' Execute(Additional flawfinder options should be configurable): - let b:ale_c_flawfinder_options = ' --foobar' + let b:ale_c_flawfinder_options = '--foobar' AssertLinter 'flawfinder', \ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t' diff --git a/test/command_callback/test_c_import_paths.vader b/test/command_callback/test_c_import_paths.vader new file mode 100644 index 00000000..80fff57b --- /dev/null +++ b/test/command_callback/test_c_import_paths.vader @@ -0,0 +1,223 @@ +Before: + " Make sure the c.vim file is loaded first. + call ale#c#FindProjectRoot(bufnr('')) + + Save g:ale_c_parse_makefile + Save g:__ale_c_project_filenames + + let g:original_project_filenames = g:__ale_c_project_filenames + + " Remove the .git/HEAD dir for C import paths for these tests. + " The tests run inside of a git repo. + let g:__ale_c_project_filenames = filter( + \ copy(g:__ale_c_project_filenames), + \ 'v:val isnot# ''.git/HEAD''' + \) + + let g:ale_c_parse_makefile = 0 + +After: + unlet! g:original_project_filenames + + call ale#assert#TearDownLinterTest() + +Execute(The C GCC handler should include 'include' directories for projects with a Makefile): + call ale#assert#SetUpLinterTest('c', 'gcc') + call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c') + let g:ale_c_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c -fsyntax-only' + \ . ' -iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include')) + \ . ' -' + +Execute(The C GCC handler should include 'include' directories for projects with a configure file): + call ale#assert#SetUpLinterTest('c', 'gcc') + call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.c') + let g:ale_c_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include')) + \ . ' -' + +Execute(The C GCC handler should include root directories for projects with .h files in them): + call ale#assert#SetUpLinterTest('c', 'gcc') + call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c') + let g:ale_c_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project')) + \ . ' -' + +Execute(The C GCC handler should include root directories for projects with .hpp files in them): + call ale#assert#SetUpLinterTest('c', 'gcc') + call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c') + let g:ale_c_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project')) + \ . ' -' + +Execute(The C Clang handler should include 'include' directories for projects with a Makefile): + call ale#assert#SetUpLinterTest('c', 'clang') + call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c') + let g:ale_c_clang_options = '' + + AssertLinter 'clang', + \ ale#Escape('clang') + \ . ' -S -x c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include')) + \ . ' -' + +Execute(The C Clang handler should include 'include' directories for projects with a configure file): + call ale#assert#SetUpLinterTest('c', 'clang') + call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c') + let g:ale_c_clang_options = '' + + AssertLinter 'clang', + \ ale#Escape('clang') + \ . ' -S -x c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project')) + \ . ' -' + +Execute(The C Clang handler should include root directories for projects with .h files in them): + call ale#assert#SetUpLinterTest('c', 'clang') + call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c') + let g:ale_c_clang_options = '' + + AssertLinter 'clang', + \ ale#Escape('clang') + \ . ' -S -x c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project')) + \ . ' -' + +Execute(The C Clang handler should include root directories for projects with .hpp files in them): + call ale#assert#SetUpLinterTest('c', 'clang') + call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c') + let g:ale_c_clang_options = '' + + AssertLinter 'clang', + \ ale#Escape('clang') + \ . ' -S -x c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project')) + \ . ' -' + +Execute(The C++ GCC handler should include 'include' directories for projects with a Makefile): + call ale#assert#SetUpLinterTest('cpp', 'gcc') + call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp') + let g:ale_cpp_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include')) + \ . ' -' + +Execute(The C++ GCC handler should include 'include' directories for projects with a configure file): + call ale#assert#SetUpLinterTest('cpp', 'gcc') + call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp') + let g:ale_cpp_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include')) + \ . ' -' + +Execute(The C++ GCC handler should include root directories for projects with .h files in them): + call ale#assert#SetUpLinterTest('cpp', 'gcc') + call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp') + let g:ale_cpp_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project')) + \ . ' -' + +Execute(The C++ GCC handler should include root directories for projects with .hpp files in them): + call ale#assert#SetUpLinterTest('cpp', 'gcc') + call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp') + let g:ale_cpp_gcc_options = '' + + AssertLinter 'gcc', + \ ale#Escape('gcc') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project')) + \ . ' -' + +Execute(The C++ Clang handler should include 'include' directories for projects with a Makefile): + call ale#assert#SetUpLinterTest('cpp', 'clang') + call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp') + let g:ale_cpp_clang_options = '' + + AssertLinter 'clang++', + \ ale#Escape('clang++') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include')) + \ . ' -' + +Execute(The C++ Clang handler should include 'include' directories for projects with a configure file): + call ale#assert#SetUpLinterTest('cpp', 'clang') + call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp') + let g:ale_cpp_clang_options = '' + + AssertLinter 'clang++', + \ ale#Escape('clang++') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include')) + \ . ' -' + +Execute(The C++ Clang handler should include root directories for projects with .h files in them): + call ale#assert#SetUpLinterTest('cpp', 'clang') + call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp') + let g:ale_cpp_clang_options = '' + + AssertLinter 'clang++', + \ ale#Escape('clang++') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project')) + \ . ' -' + +Execute(The C++ Clang handler should include root directories for projects with .hpp files in them): + call ale#assert#SetUpLinterTest('cpp', 'clang') + call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp') + let g:ale_cpp_clang_options = '' + + AssertLinter 'clang++', + \ ale#Escape('clang++') + \ . ' -S -x c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir')) + \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project')) + \ . ' -' + +Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them): + call ale#assert#SetUpLinterTest('cpp', 'clangtidy') + call ale#test#SetFilename('../test_c_projects/json_project/subdir/file.cpp') + + AssertLinter 'clang-tidy', + \ ale#Escape('clang-tidy') + \ . ' -checks=' . ale#Escape('*') . ' %s ' + \ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/json_project/build')) diff --git a/test/command_callback/test_cpp_cquery_command_callbacks.vader b/test/command_callback/test_cpp_cquery_command_callbacks.vader index b355d052..682c90d5 100644 --- a/test/command_callback/test_cpp_cquery_command_callbacks.vader +++ b/test/command_callback/test_cpp_cquery_command_callbacks.vader @@ -7,6 +7,20 @@ Before: After: call ale#assert#TearDownLinterTest() +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('cquery_paths/with_compile_commands_json/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .cquery file): + AssertLSPProject '' + + call ale#test#SetFilename('cquery_paths/with_cquery/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_cquery') + Execute(The executable should be configurable): AssertLinter 'cquery', ale#Escape('cquery') diff --git a/test/command_callback/test_cuda_nvcc_command_callbacks.vader b/test/command_callback/test_cuda_nvcc_command_callbacks.vader index 9e2b5ac6..4578d052 100644 --- a/test/command_callback/test_cuda_nvcc_command_callbacks.vader +++ b/test/command_callback/test_cuda_nvcc_command_callbacks.vader @@ -12,3 +12,9 @@ Execute(The executable should be configurable): AssertLinter 'foobar', \ ale#Escape('foobar') . ' -cuda -std=c++11 %s -o ' . g:ale#util#nul_file + +Execute(The options should be configurable): + let g:ale_cuda_nvcc_options = '--foobar' + + AssertLinter 'nvcc', + \ ale#Escape('nvcc') . ' -cuda --foobar %s -o ' . g:ale#util#nul_file diff --git a/test/command_callback/test_elm_make_command_callback.vader b/test/command_callback/test_elm_make_command_callback.vader new file mode 100644 index 00000000..6d95676f --- /dev/null +++ b/test/command_callback/test_elm_make_command_callback.vader @@ -0,0 +1,32 @@ +Before: + call ale#assert#SetUpLinterTest('elm', 'make') + +After: + unlet! g:executable + + call ale#assert#TearDownLinterTest() + +Execute(should get valid executable with default params): + call ale#test#SetFilename('../elm-test-files/app/testfile.elm') + + let g:executable = ale#path#Simplify(g:dir . '/../elm-test-files/app/node_modules/.bin/elm') + + AssertLinter g:executable, + \ ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t' + +Execute(should get valid executable with 'use_global' params): + let g:ale_elm_make_use_global = 1 + + call ale#test#SetFilename('../elm-test-files/app/testfile.elm') + + AssertLinter 'elm', + \ ale#Escape('elm') . ' make --report=json --output=/dev/null %t' + +Execute(should get valid executable with 'use_global' and 'executable' params): + let g:ale_elm_make_executable = 'other-elm' + let g:ale_elm_make_use_global = 1 + + call ale#test#SetFilename('../elm-test-files/app/testfile.elm') + + AssertLinter 'other-elm', + \ ale#Escape('other-elm') . ' make --report=json --output=/dev/null %t' diff --git a/test/command_callback/test_fsc_command_callback.vader b/test/command_callback/test_fsc_command_callback.vader index 5fb5e7fa..278e7c16 100644 --- a/test/command_callback/test_fsc_command_callback.vader +++ b/test/command_callback/test_fsc_command_callback.vader @@ -10,4 +10,4 @@ Execute(The default executable and command should be correct): Given scala.sbt(An empty SBT file): Execute(fsc should not be run for sbt files): - AssertLinter '', '' + AssertLinterNotExecuted diff --git a/test/command_callback/test_gawk_command_callback.vader b/test/command_callback/test_gawk_command_callback.vader index 6bc0a438..ba9f59ab 100644 --- a/test/command_callback/test_gawk_command_callback.vader +++ b/test/command_callback/test_gawk_command_callback.vader @@ -6,14 +6,14 @@ After: Execute(The default command should be correct): AssertLinter 'gawk', - \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }''' + \ ale#Escape('gawk') . ' --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') \ . ' -f %t --lint /dev/null' Execute(The executable should be configurable): let b:ale_awk_gawk_executable = '/other/gawk' AssertLinter '/other/gawk', - \ ale#Escape('/other/gawk') . ' --source ''BEGIN { exit } END { exit 1 }''' + \ ale#Escape('/other/gawk') . ' --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') \ . ' -f %t --lint /dev/null' Execute(The options should be configurable): @@ -21,5 +21,5 @@ Execute(The options should be configurable): let b:ale_awk_gawk_options = '--something' AssertLinter 'gawk', - \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }''' + \ ale#Escape('gawk') . ' --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') \ . ' --something -f %t --lint /dev/null' diff --git a/test/command_callback/test_gfortran_command_callback.vader b/test/command_callback/test_gfortran_command_callback.vader index a6ab50cd..3e6ef951 100644 --- a/test/command_callback/test_gfortran_command_callback.vader +++ b/test/command_callback/test_gfortran_command_callback.vader @@ -5,20 +5,20 @@ After: call ale#assert#TearDownLinterTest() Execute(The fortran gcc command callback should return the correct default string): - AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wall -' + AssertLinter 'gcc', ale#Escape('gcc') . ' -S -x f95 -fsyntax-only -ffree-form -Wall -' Execute(The fortran gcc command callback should let you set options): let g:ale_fortran_gcc_options = '-Wotherthings' - AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wotherthings -' + AssertLinter 'gcc', ale#Escape('gcc') . ' -S -x f95 -fsyntax-only -ffree-form -Wotherthings -' Execute(The fortran gcc command callback should let you use -ffixed-form): let g:ale_fortran_gcc_use_free_form = 0 - AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffixed-form -Wall -' + AssertLinter 'gcc', ale#Escape('gcc') . ' -S -x f95 -fsyntax-only -ffixed-form -Wall -' Execute(The fortran executable should be configurable): let g:ale_fortran_gcc_executable = 'gfortran' AssertLinter 'gfortran', - \ 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -' + \ ale#Escape('gfortran') . ' -S -x f95 -fsyntax-only -ffree-form -Wall -' diff --git a/test/command_callback/test_haskell_hie_callbacks.vader b/test/command_callback/test_haskell_hie_callbacks.vader new file mode 100644 index 00000000..5bd2794c --- /dev/null +++ b/test/command_callback/test_haskell_hie_callbacks.vader @@ -0,0 +1,27 @@ +Before: + call ale#assert#SetUpLinterTest('haskell', 'hie') + + Save &filetype + let &filetype = 'haskell' + +After: + call ale#assert#TearDownLinterTest() + +Execute(The language string should be correct): + AssertLSPLanguage 'haskell' + +Execute(The default executable should be correct): + AssertLinter 'hie', + \ ale#Escape('hie') . ' --lsp' + +Execute(The project root should be detected correctly): + AssertLSPProject g:dir + + call ale#test#SetFilename('hie_paths/file.hs') + + AssertLSPProject ale#path#Simplify(g:dir . '/hie_paths') + +Execute(The executable should be configurable): + let g:ale_haskell_hie_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') . ' --lsp' diff --git a/test/command_callback/test_javascript_tsserver_command_callback.vader b/test/command_callback/test_javascript_tsserver_command_callback.vader new file mode 100644 index 00000000..638dd873 --- /dev/null +++ b/test/command_callback/test_javascript_tsserver_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('javascript', 'tsserver') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'tsserver', ale#Escape('tsserver') diff --git a/test/command_callback/test_luac_command_callback.vader b/test/command_callback/test_luac_command_callback.vader index 8a2345ec..55f39cba 100644 --- a/test/command_callback/test_luac_command_callback.vader +++ b/test/command_callback/test_luac_command_callback.vader @@ -5,9 +5,9 @@ After: call ale#assert#TearDownLinterTest() Execute(The default command should be correct): - AssertLinter 'luac', ale#Escape('luac') . ' -p - ' + AssertLinter 'luac', ale#Escape('luac') . ' -p -' Execute(The luac executable should be configurable): let g:ale_lua_luac_executable = 'luac.sh' - AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p - ' + AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p -' diff --git a/test/command_callback/test_luacheck_command_callback.vader b/test/command_callback/test_luacheck_command_callback.vader index 58d0cdc0..f0ef221c 100644 --- a/test/command_callback/test_luacheck_command_callback.vader +++ b/test/command_callback/test_luacheck_command_callback.vader @@ -6,7 +6,7 @@ After: Execute(The lua luacheck command callback should return the correct default string): AssertLinter 'luacheck', - \ ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -' + \ ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -' Execute(The lua luacheck command callback should let you set options): let g:ale_lua_luacheck_options = '--config filename' @@ -20,4 +20,4 @@ Execute(The luacheck executable should be configurable): let g:ale_lua_luacheck_executable = 'luacheck.sh' AssertLinter 'luacheck.sh', - \ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -' + \ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -' diff --git a/test/command_callback/test_mercury_mmc_command_callback.vader b/test/command_callback/test_mercury_mmc_command_callback.vader index 2948e799..ab61fddf 100644 --- a/test/command_callback/test_mercury_mmc_command_callback.vader +++ b/test/command_callback/test_mercury_mmc_command_callback.vader @@ -8,18 +8,18 @@ After: Execute(The default command should be correct): AssertLinter 'mmc', \ ale#path#BufferCdString(bufnr('')) - \ . 'mmc --errorcheck-only --make --output-compile-error-lines 100 dummy' + \ . ale#Escape('mmc') . ' --errorcheck-only --make --output-compile-error-lines 100 dummy' Execute(The executable should be configurable): let b:ale_mercury_mmc_executable = 'foo' AssertLinter 'foo', \ ale#path#BufferCdString(bufnr('')) - \ . 'foo --errorcheck-only --make --output-compile-error-lines 100 dummy' + \ . ale#Escape('foo') . ' --errorcheck-only --make --output-compile-error-lines 100 dummy' Execute(The options should be configurable): let b:ale_mercury_mmc_options = '--bar' AssertLinter 'mmc', \ ale#path#BufferCdString(bufnr('')) - \ . 'mmc --errorcheck-only --bar dummy' + \ . ale#Escape('mmc') . ' --errorcheck-only --bar dummy' diff --git a/test/command_callback/test_nasm_nasm_command_callbacks.vader b/test/command_callback/test_nasm_nasm_command_callbacks.vader index 4e0cf608..0d3e572a 100644 --- a/test/command_callback/test_nasm_nasm_command_callbacks.vader +++ b/test/command_callback/test_nasm_nasm_command_callbacks.vader @@ -2,7 +2,7 @@ Before: call ale#assert#SetUpLinterTest('nasm', 'nasm') let b:command_tail = - \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s' + \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s' let b:command_tail_opt = \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s' diff --git a/test/command_callback/test_phpcs_command_callback.vader b/test/command_callback/test_phpcs_command_callback.vader new file mode 100644 index 00000000..941a92d6 --- /dev/null +++ b/test/command_callback/test_phpcs_command_callback.vader @@ -0,0 +1,29 @@ +Before: + call ale#assert#SetUpLinterTest('php', 'phpcs') + +After: + unlet! g:executable + + call ale#assert#TearDownLinterTest() + +Execute(The local phpcs executable should be used): + call ale#test#SetFilename('../phpcs-test-files/project-with-phpcs/foo/test.php') + + let g:executable = ale#path#Simplify(g:dir . '/../phpcs-test-files/project-with-phpcs/vendor/bin/phpcs') + + AssertLinter g:executable, + \ ale#Escape(g:executable) . ' -s --report=emacs --stdin-path=%s' + +Execute(use_global should override local executable detection): + let g:ale_php_phpcs_use_global = 1 + + call ale#test#SetFilename('../phpcs-test-files/project-with-phpcs/foo/test.php') + + AssertLinter 'phpcs', + \ ale#Escape('phpcs') . ' -s --report=emacs --stdin-path=%s' + +Execute(Projects without local executables should use the global one): + call ale#test#SetFilename('../phpcs-test-files/project-without-phpcs/foo/test.php') + + AssertLinter 'phpcs', + \ ale#Escape('phpcs') . ' -s --report=emacs --stdin-path=%s' diff --git a/test/command_callback/test_scalac_command_callback.vader b/test/command_callback/test_scalac_command_callback.vader index 115731b3..ea5ae109 100644 --- a/test/command_callback/test_scalac_command_callback.vader +++ b/test/command_callback/test_scalac_command_callback.vader @@ -10,4 +10,4 @@ Execute(The default executable and command should be correct): Given scala.sbt(An empty SBT file): Execute(scalac should not be run for sbt files): - AssertLinter '', '' + AssertLinterNotExecuted diff --git a/test/command_callback/test_swaglint_command_callback.vader b/test/command_callback/test_swaglint_command_callback.vader index fe8fb722..68fb1406 100644 --- a/test/command_callback/test_swaglint_command_callback.vader +++ b/test/command_callback/test_swaglint_command_callback.vader @@ -5,25 +5,25 @@ After: call ale#assert#TearDownLinterTest() Execute(The yaml swaglint command callback should return the correct default string): - AssertLinter 'swaglint', 'swaglint -r compact --stdin' + AssertLinter 'swaglint', ale#Escape('swaglint') . ' -r compact --stdin' Execute(The yaml swaglint command callback should be configurable): let g:ale_yaml_swaglint_executable = '~/.local/bin/swaglint' AssertLinter '~/.local/bin/swaglint', - \ '~/.local/bin/swaglint -r compact --stdin' + \ ale#Escape('~/.local/bin/swaglint') . ' -r compact --stdin' Execute(The yaml swaglint command callback should allow a global installation to be used): let g:ale_yaml_swaglint_executable = '/usr/local/bin/swaglint' let g:ale_yaml_swaglint_use_global = 1 AssertLinter '/usr/local/bin/swaglint', - \ '/usr/local/bin/swaglint -r compact --stdin' + \ ale#Escape('/usr/local/bin/swaglint') . ' -r compact --stdin' Execute(The yaml swaglint command callback should allow a local installation to be used): call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml') AssertLinter \ ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint'), - \ ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint') + \ ale#Escape(ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint')) \ . ' -r compact --stdin' diff --git a/test/command_callback/test_terraform_tflint_command_callback.vader b/test/command_callback/test_terraform_tflint_command_callback.vader index c32d9bcf..0cef0176 100644 --- a/test/command_callback/test_terraform_tflint_command_callback.vader +++ b/test/command_callback/test_terraform_tflint_command_callback.vader @@ -17,3 +17,12 @@ Execute(Overriding options should work): let g:ale_terraform_tflint_options = '--whatever' AssertLinter 'fnord', ale#Escape('fnord') . ' --whatever -f json %t' + +Execute(Configuration files should be found): + call ale#test#SetFilename('../tflint-test-files/foo/bar.tf') + + AssertLinter 'tflint', + \ ale#Escape('tflint') + \ . ' --config ' + \ . ale#Escape(ale#path#Simplify(g:dir . '/../tflint-test-files/foo/.tflint.hcl')) + \ . ' -f json %t' diff --git a/test/command_callback/test_typescript_tsserver_command_callback.vader b/test/command_callback/test_typescript_tsserver_command_callback.vader new file mode 100644 index 00000000..719ac184 --- /dev/null +++ b/test/command_callback/test_typescript_tsserver_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('typescript', 'tsserver') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'tsserver', ale#Escape('tsserver') diff --git a/test/command_callback/test_yang_lsp_command_callbacks.vader b/test/command_callback/test_yang_lsp_command_callbacks.vader new file mode 100644 index 00000000..5be7501f --- /dev/null +++ b/test/command_callback/test_yang_lsp_command_callbacks.vader @@ -0,0 +1,12 @@ +Before: + call ale#assert#SetUpLinterTest('yang', 'yang_lsp') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The executable should be configurable): + AssertLinter 'yang-language-server', ale#Escape('yang-language-server') + + let b:ale_yang_lsp_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') diff --git a/test/fixers/test_hackfmt_fixer_callback.vader b/test/fixers/test_hackfmt_fixer_callback.vader index ed78fc85..d294c15e 100644 --- a/test/fixers/test_hackfmt_fixer_callback.vader +++ b/test/fixers/test_hackfmt_fixer_callback.vader @@ -1,10 +1,10 @@ Before: - Save g:ale_php_hackfmt_executable - Save g:ale_php_hackfmt_options + Save g:ale_hack_hackfmt_executable + Save g:ale_hack_hackfmt_options " Use an invalid global executable, so we don't match it. - let g:ale_php_hackfmt_executable = 'xxxinvalid' - let g:ale_php_hackfmt_options = '' + let g:ale_hack_hackfmt_executable = 'xxxinvalid' + let g:ale_hack_hackfmt_options = '' call ale#test#SetDirectory('/testplugin/test/fixers') @@ -14,7 +14,7 @@ After: call ale#test#RestoreDirectory() Execute(The hackfmt callback should return the correct default values): - call ale#test#SetFilename('../hack_files/testfile.php') + call ale#test#SetFilename('../hack_files/testfile.hack') AssertEqual \ { @@ -25,8 +25,8 @@ Execute(The hackfmt callback should return the correct default values): \ ale#fixers#hackfmt#Fix(bufnr('')) Execute(The hackfmt callback should include custom hackfmt options): - let g:ale_php_hackfmt_options = "--some-option" - call ale#test#SetFilename('../hack_files/testfile.php') + let g:ale_hack_hackfmt_options = "--some-option" + call ale#test#SetFilename('../hack_files/testfile.hack') AssertEqual \ { diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader index 2018c3a6..44245630 100644 --- a/test/fixers/test_prettier_fixer_callback.vader +++ b/test/fixers/test_prettier_fixer_callback.vader @@ -222,6 +222,20 @@ Execute(Should set --parser based on filetype, Vue): \ }, \ ale#fixers#prettier#ApplyFixForVersion(bufnr(''), ['1.6.0']) +Execute(Should set --parser based on filetype, YAML): + call ale#test#SetFilename('../prettier-test-files/testfile') + + set filetype=yaml + + AssertEqual + \ { + \ 'command': 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ . ale#Escape(g:ale_javascript_prettier_executable) + \ . ' --parser yaml' + \ . ' --stdin-filepath %s --stdin', + \ }, + \ ale#fixers#prettier#ApplyFixForVersion(bufnr(''), ['1.6.0']) + Execute(Should set --parser based on first filetype of multiple filetypes): call ale#test#SetFilename('../prettier-test-files/testfile') @@ -235,3 +249,21 @@ Execute(Should set --parser based on first filetype of multiple filetypes): \ . ' --stdin-filepath %s --stdin', \ }, \ ale#fixers#prettier#ApplyFixForVersion(bufnr(''), ['1.6.0']) + +Execute(The prettier_d post-processor should permit regular JavaScript content): + AssertEqual + \ [ + \ 'const x = ''Error: foo''', + \ 'const y = 3', + \ ], + \ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [ + \ 'const x = ''Error: foo''', + \ 'const y = 3', + \ ]) + +Execute(The prettier_d post-processor should handle error messages correctly): + AssertEqual + \ [], + \ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [ + \ 'SyntaxError: Unexpected token, expected "," (36:28)', + \ ]) diff --git a/test/handler/test_clang_handler.vader b/test/handler/test_clang_handler.vader index 278737a8..cc8eabd0 100644 --- a/test/handler/test_clang_handler.vader +++ b/test/handler/test_clang_handler.vader @@ -8,9 +8,20 @@ Execute(clang errors from included files should be parsed correctly): \ 'type': 'E', \ 'text': 'expected identifier or ''(''', \ }, + \ { + \ 'lnum': 3, + \ 'text': 'Error found in header. See :ALEDetail', + \ 'detail': join([ + \ 'In file included from <stdin>:3:', + \ 'In file included from ./a.h:1:', + \ './b.h:1:1: error: expected identifier or ''(''', + \ '{{{', + \ '^', + \ ], "\n"), + \ }, \ ], - \ ale#handlers#gcc#HandleGCCFormat(347, [ - \ 'In file included from test.c:3:', + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ + \ 'In file included from <stdin>:3:', \ 'In file included from ./a.h:1:', \ './b.h:1:1: error: expected identifier or ''(''', \ '{{{', diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader index 678d3f42..3daa9e60 100644 --- a/test/handler/test_gcc_handler.vader +++ b/test/handler/test_gcc_handler.vader @@ -1,7 +1,7 @@ Execute(The GCC handler should ignore other lines of output): AssertEqual \ [], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ 'foo', \ 'bar', \ 'baz', @@ -17,12 +17,24 @@ Execute(GCC errors from included files should be parsed correctly): \ 'type': 'E', \ 'text': 'expected identifier or ''('' before ''{'' token', \ }, + \ { + \ 'lnum': 3, + \ 'col': 2, + \ 'text': 'Error found in header. See :ALEDetail', + \ 'detail': join([ + \ 'In file included from <stdin>:3:2:', + \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token', + \ ' {{{', + \ ' ^', + \ ], "\n"), + \ }, \ ], - \ ale#handlers#gcc#HandleGCCFormat(347, [ - \ 'In file included from <stdin>:3:0:', + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ + \ 'In file included from <stdin>:3:2:', \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token', \ ' {{{', \ ' ^', + \ 'compilation terminated.', \ ]) AssertEqual @@ -34,13 +46,25 @@ Execute(GCC errors from included files should be parsed correctly): \ 'type': 'E', \ 'text': 'expected identifier or ''('' before ''{'' token', \ }, + \ { + \ 'lnum': 5, + \ 'text': 'Error found in header. See :ALEDetail', + \ 'detail': join([ + \ 'In file included from a.h:1:0,', + \ ' from <stdin>:5:', + \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token', + \ ' {{{', + \ ' ^', + \ ], "\n"), + \ }, \ ], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ 'In file included from a.h:1:0,', - \ ' from test.c:3:', + \ ' from <stdin>:5:', \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token', \ ' {{{', \ ' ^', + \ 'compilation terminated.', \ ]) AssertEqual @@ -59,16 +83,31 @@ Execute(GCC errors from included files should be parsed correctly): \ 'type': 'E', \ 'text': 'unknown type name ''other_bad_type''', \ }, + \ { + \ 'lnum': 3, + \ 'text': 'Error found in header. See :ALEDetail', + \ 'detail': join([ + \ 'In file included from a.h:1:0,', + \ ' from <stdin>:3:', + \ 'b.h:1:1: error: unknown type name ‘bad_type’', + \ ' bad_type x;', + \ ' ^', + \ 'b.h:2:1: error: unknown type name ‘other_bad_type’', + \ ' other_bad_type y;', + \ ' ^', + \ ], "\n"), + \ }, \ ], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ 'In file included from a.h:1:0,', - \ ' from test.c:3:', + \ ' from <stdin>:3:', \ 'b.h:1:1: error: unknown type name ‘bad_type’', \ ' bad_type x;', \ ' ^', \ 'b.h:2:1: error: unknown type name ‘other_bad_type’', \ ' other_bad_type y;', \ ' ^', + \ 'compilation terminated.', \ ]) Execute(The GCC handler shouldn't complain about #pragma once for headers): @@ -76,7 +115,7 @@ Execute(The GCC handler shouldn't complain about #pragma once for headers): AssertEqual \ [], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]', \ ]) @@ -84,7 +123,7 @@ Execute(The GCC handler shouldn't complain about #pragma once for headers): AssertEqual \ [], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]', \ ]) @@ -119,7 +158,7 @@ Execute(The GCC handler should handle syntax errors): \ 'text': 'expected '';'' before ''o''' \ }, \ ], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ '<stdin>:6:12: error: invalid suffix "p" on integer constant', \ '<stdin>:17:5: error: invalid suffix "n" on integer constant', \ '<stdin>:4: error: variable or field ''foo'' declared void', @@ -130,11 +169,27 @@ Execute(The GCC handler should handle syntax errors): Execute(The GCC handler should handle notes with no previous message): AssertEqual \ [], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ '<stdin>:1:1: note: x', \ '<stdin>:1:1: note: x', \ ]) +Execute(The GCC handler should attach notes to previous messages): + AssertEqual + \ [ + \ { + \ 'lnum': 6, + \ 'col': 12, + \ 'type': 'E', + \ 'text': 'Some error', + \ 'detail': "Some error\n<stdin>:1:1: note: x", + \ }, + \ ], + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ + \ '-:6:12: error: Some error', + \ '<stdin>:1:1: note: x', + \ ]) + Execute(The GCC handler should interpret - as being the current file): AssertEqual \ [ @@ -145,7 +200,7 @@ Execute(The GCC handler should interpret - as being the current file): \ 'text': 'Some error', \ }, \ ], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ '-:6:12: error: Some error', \ ]) @@ -159,6 +214,6 @@ Execute(The GCC handler should handle fatal error messages due to missing files) \ 'text': 'foo.h: No such file or directory' \ }, \ ], - \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ \ '<stdin>:3:12: fatal error: foo.h: No such file or directory', \ ]) diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index 444272aa..df187a24 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -18,7 +18,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle errors): \ 'col': 11, \ 'end_lnum': 5, \ 'end_col': 16, - \ 'nr': 'some-error', + \ 'code': 'some-error', \ } \ ], \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ @@ -39,7 +39,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle warnings): \ 'col': 4, \ 'end_lnum': 2, \ 'end_col': 4, - \ 'nr': 'some-warning', + \ 'code': 'some-warning', \ } \ ], \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ @@ -60,7 +60,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing se \ 'col': 11, \ 'end_lnum': 5, \ 'end_col': 16, - \ 'nr': 'some-error', + \ 'code': 'some-error', \ } \ ], \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ @@ -89,6 +89,26 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes) \ }, \ ]}}) +Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningless code): + AssertEqual [ + \ { + \ 'type': 'E', + \ 'text': 'Something went wrong!', + \ 'lnum': 3, + \ 'col': 11, + \ 'end_lnum': 5, + \ 'end_col': 16, + \ } + \ ], + \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ + \ { + \ 'range': Range(2, 10, 4, 15), + \ 'message': 'Something went wrong!', + \ 'code': -1, + \ }, + \ ]}}) + + Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages): AssertEqual [ \ { @@ -126,6 +146,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver respon \ { \ 'type': 'E', \ 'nr': 2365, + \ 'code': '2365', \ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.', \ 'lnum': 1, \ 'col': 11, @@ -142,6 +163,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle warnings from t \ 'lnum': 27, \ 'col': 3, \ 'nr': 2515, + \ 'code': '2515', \ 'end_lnum': 27, \ 'type': 'W', \ 'end_col': 14, @@ -157,6 +179,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle suggestions fro \ 'lnum': 27, \ 'col': 3, \ 'nr': 2515, + \ 'code': '2515', \ 'end_lnum': 27, \ 'type': 'I', \ 'end_col': 14, diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader deleted file mode 100644 index 70b25070..00000000 --- a/test/test_c_import_paths.vader +++ /dev/null @@ -1,254 +0,0 @@ -Before: - " Make sure the c.vim file is loaded first. - call ale#c#FindProjectRoot(bufnr('')) - - Save g:ale_c_parse_makefile - Save g:ale_c_gcc_options - Save g:ale_c_clang_options - Save g:ale_cpp_gcc_options - Save g:ale_cpp_clang_options - Save g:__ale_c_project_filenames - - let g:original_project_filenames = g:__ale_c_project_filenames - - " Remove the .git/HEAD dir for C import paths for these tests. - " The tests run inside of a git repo. - let g:__ale_c_project_filenames = filter( - \ copy(g:__ale_c_project_filenames), - \ 'v:val isnot# ''.git/HEAD''' - \) - - call ale#test#SetDirectory('/testplugin/test') - - let g:ale_c_parse_makefile = 0 - let g:ale_c_gcc_options = '' - let g:ale_c_clang_options = '' - let g:ale_cpp_gcc_options = '' - let g:ale_cpp_clang_options = '' - -After: - Restore - - unlet! g:original_project_filenames - - call ale#test#RestoreDirectory() - call ale#linter#Reset() - -Execute(The C GCC handler should include 'include' directories for projects with a Makefile): - runtime! ale_linters/c/gcc.vim - - call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' ' - \ . ' -' - \ , ale_linters#c#gcc#GetCommand(bufnr(''), []) - -Execute(The C GCC handler should include 'include' directories for projects with a configure file): - runtime! ale_linters/c/gcc.vim - - call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.c') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' ' - \ . ' -' - \ , ale_linters#c#gcc#GetCommand(bufnr(''), []) - -Execute(The C GCC handler should include root directories for projects with .h files in them): - runtime! ale_linters/c/gcc.vim - - call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' ' - \ . ' -' - \ , ale_linters#c#gcc#GetCommand(bufnr(''), []) - -Execute(The C GCC handler should include root directories for projects with .hpp files in them): - runtime! ale_linters/c/gcc.vim - - call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.c') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' ' - \ . ' -' - \ , ale_linters#c#gcc#GetCommand(bufnr(''), []) - -Execute(The C Clang handler should include 'include' directories for projects with a Makefile): - runtime! ale_linters/c/clang.vim - - call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') - - AssertEqual - \ ale#Escape('clang') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' ' - \ . ' -' - \ , ale_linters#c#clang#GetCommand(bufnr(''), []) - -Execute(The C Clang handler should include 'include' directories for projects with a configure file): - runtime! ale_linters/c/clang.vim - - call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c') - - AssertEqual - \ ale#Escape('clang') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' ' - \ . ' -' - \ , ale_linters#c#clang#GetCommand(bufnr(''), []) - -Execute(The C Clang handler should include root directories for projects with .h files in them): - runtime! ale_linters/c/clang.vim - - call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c') - - AssertEqual - \ ale#Escape('clang') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' ' - \ . ' -' - \ , ale_linters#c#clang#GetCommand(bufnr(''), []) - -Execute(The C Clang handler should include root directories for projects with .hpp files in them): - runtime! ale_linters/c/clang.vim - - call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.c') - - AssertEqual - \ ale#Escape('clang') - \ . ' -S -x c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' ' - \ . ' -' - \ , ale_linters#c#clang#GetCommand(bufnr(''), []) - -Execute(The C++ GCC handler should include 'include' directories for projects with a Makefile): - runtime! ale_linters/cpp/gcc.vim - - call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' ' - \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) - -Execute(The C++ GCC handler should include 'include' directories for projects with a configure file): - runtime! ale_linters/cpp/gcc.vim - - call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' ' - \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) - -Execute(The C++ GCC handler should include root directories for projects with .h files in them): - runtime! ale_linters/cpp/gcc.vim - - call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' ' - \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) - -Execute(The C++ GCC handler should include root directories for projects with .hpp files in them): - runtime! ale_linters/cpp/gcc.vim - - call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('gcc') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' ' - \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) - -Execute(The C++ Clang handler should include 'include' directories for projects with a Makefile): - runtime! ale_linters/cpp/clang.vim - - call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('clang++') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' ' - \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) - -Execute(The C++ Clang handler should include 'include' directories for projects with a configure file): - runtime! ale_linters/cpp/clang.vim - - call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('clang++') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' ' - \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) - -Execute(The C++ Clang handler should include root directories for projects with .h files in them): - runtime! ale_linters/cpp/clang.vim - - call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('clang++') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' ' - \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) - -Execute(The C++ Clang handler should include root directories for projects with .hpp files in them): - runtime! ale_linters/cpp/clang.vim - - call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('clang++') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' ' - \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) - -Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them): - runtime! ale_linters/cpp/clangtidy.vim - - call ale#test#SetFilename('test_c_projects/json_project/subdir/file.cpp') - - AssertEqual - \ ale#Escape('clang-tidy') - \ . ' -checks=' . ale#Escape('*') . ' %s ' - \ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/json_project/build')) - \ , ale_linters#cpp#clangtidy#GetCommand(bufnr('')) diff --git a/test/test_elm_executable_detection.vader b/test/test_elm_executable_detection.vader deleted file mode 100644 index 9146eea6..00000000 --- a/test/test_elm_executable_detection.vader +++ /dev/null @@ -1,36 +0,0 @@ -Before: - call ale#test#SetDirectory('/testplugin/test') - runtime ale_linters/elm/make.vim - -After: - unlet! g:ale_elm_make_use_global - unlet! g:ale_elm_make_executable - - call ale#test#RestoreDirectory() - -Execute(should get valid executable with default params): - call ale#test#SetFilename('elm-test-files/app/testfile.elm') - - AssertEqual - \ ale#path#Simplify(g:dir . '/elm-test-files/app/node_modules/.bin/elm'), - \ ale_linters#elm#make#GetExecutable(bufnr('')) - -Execute(should get valid executable with 'use_global' params): - let g:ale_elm_make_use_global = 1 - - call ale#test#SetFilename('elm-test-files/app/testfile.elm') - - AssertEqual - \ 'elm', - \ ale_linters#elm#make#GetExecutable(bufnr('')) - -Execute(should get valid executable with 'use_global' and 'executable' params): - let g:ale_elm_make_executable = 'other-elm' - let g:ale_elm_make_use_global = 1 - - call ale#test#SetFilename('elm-test-files/app/testfile.elm') - - AssertEqual - \ 'other-elm', - \ ale_linters#elm#make#GetExecutable(bufnr('')) - diff --git a/test/test_engine_lsp_response_handling.vader b/test/test_engine_lsp_response_handling.vader index 517d82c0..818659db 100644 --- a/test/test_engine_lsp_response_handling.vader +++ b/test/test_engine_lsp_response_handling.vader @@ -63,7 +63,7 @@ Execute(tsserver syntax error responses should be handled correctly): \ 'vcol': 0, \ 'nr': 1005, \ 'type': 'E', - \ 'text': ''','' expected.', + \ 'text': '1005: '','' expected.', \ 'valid': 1, \ 'pattern': '', \ }, @@ -136,7 +136,7 @@ Execute(tsserver semantic error responses should be handled correctly): \ 'vcol': 0, \ 'nr': 1005, \ 'type': 'E', - \ 'text': 'Some semantic error', + \ 'text': '1005: Some semantic error', \ 'valid': 1, \ 'pattern': '', \ }, diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader index 7f0e3fcb..53f566e9 100644 --- a/test/test_go_to_definition.vader +++ b/test/test_go_to_definition.vader @@ -111,7 +111,7 @@ Execute(Other files should be jumped to for definition responses): AssertEqual \ [ - \ 'edit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), + \ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), \ ], \ g:expr_list AssertEqual [3, 7], getpos('.')[1:2] @@ -136,7 +136,7 @@ Execute(Other files should be jumped to for definition responses in tabs too): AssertEqual \ [ - \ 'tabedit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), + \ 'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), \ ], \ g:expr_list AssertEqual [3, 7], getpos('.')[1:2] @@ -206,7 +206,7 @@ Execute(Other files should be jumped to for LSP definition responses): AssertEqual \ [ - \ 'edit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), + \ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), \ ], \ g:expr_list AssertEqual [3, 7], getpos('.')[1:2] @@ -251,7 +251,7 @@ Execute(Other files should be jumped to in tabs for LSP definition responses): AssertEqual \ [ - \ 'tabedit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), + \ 'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), \ ], \ g:expr_list AssertEqual [3, 7], getpos('.')[1:2] @@ -282,7 +282,7 @@ Execute(Definition responses with lists should be handled): AssertEqual \ [ - \ 'edit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), + \ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')), \ ], \ g:expr_list AssertEqual [3, 7], getpos('.')[1:2] diff --git a/test/test_ignoring_linters.vader b/test/test_ignoring_linters.vader index af31fce3..1ddd30e8 100644 --- a/test/test_ignoring_linters.vader +++ b/test/test_ignoring_linters.vader @@ -190,6 +190,7 @@ Execute(Buffer ignore lists should be applied for tsserver): \ 'lnum': 2, \ 'col': 14, \ 'nr': 1005, + \ 'code': '1005', \ 'type': 'E', \ 'end_col': 15, \ 'end_lnum': 2, diff --git a/test/test_phpcs_executable_detection.vader b/test/test_phpcs_executable_detection.vader deleted file mode 100644 index 020bfac3..00000000 --- a/test/test_phpcs_executable_detection.vader +++ /dev/null @@ -1,39 +0,0 @@ -Before: - Save g:ale_php_phpcs_executable - Save g:ale_php_phpcs_use_global - - let g:ale_php_phpcs_executable = 'phpcs_test' - let g:ale_php_phpcs_use_global = 0 - - call ale#test#SetDirectory('/testplugin/test') - - runtime ale_linters/php/phpcs.vim - -After: - Restore - - call ale#test#RestoreDirectory() - call ale#linter#Reset() - -Execute(project with phpcs should use local by default): - call ale#test#SetFilename('phpcs-test-files/project-with-phpcs/foo/test.php') - - AssertEqual - \ ale#path#Simplify(g:dir . '/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs'), - \ ale_linters#php#phpcs#GetExecutable(bufnr('')) - -Execute(use-global should override local detection): - let g:ale_php_phpcs_use_global = 1 - - call ale#test#SetFilename('phpcs-test-files/project-with-phpcs/foo/test.php') - - AssertEqual - \ 'phpcs_test', - \ ale_linters#php#phpcs#GetExecutable(bufnr('')) - -Execute(project without phpcs should use global): - call ale#test#SetFilename('phpcs-test-files/project-without-phpcs/foo/test.php') - - AssertEqual - \ 'phpcs_test', - \ ale_linters#php#phpcs#GetExecutable(bufnr('')) diff --git a/test/test_tflint_config_detection.vader b/test/test_tflint_config_detection.vader deleted file mode 100644 index 3500869b..00000000 --- a/test/test_tflint_config_detection.vader +++ /dev/null @@ -1,18 +0,0 @@ -Before: - call ale#test#SetDirectory('/testplugin/test') - runtime ale_linters/terraform/tflint.vim - -After: - call ale#test#RestoreDirectory() - call ale#linter#Reset() - -Execute(adjacent config file should be found): - call ale#test#SetFilename('tflint-test-files/foo/bar.tf') - AssertEqual - \ ( - \ ale#Escape('tflint') - \ . ' --config ' - \ . ale#Escape(ale#path#Simplify(g:dir . '/tflint-test-files/foo/.tflint.hcl')) - \ . ' -f json %t' - \ ), - \ ale_linters#terraform#tflint#GetCommand(bufnr('')) |