diff options
author | Bjorn Neergaard <bjorn@neersighted.com> | 2018-11-29 14:57:35 -0700 |
---|---|---|
committer | Bjorn Neergaard <bjorn@neersighted.com> | 2018-11-29 14:57:35 -0700 |
commit | d2b0ae8108b2ee395d4eb43c49d68b322a023a30 (patch) | |
tree | bb8145e69bf1bcb8968b29cb1a68c47ceb83674d /test/command_callback | |
parent | ef641dda80f45cb979bc93c2513c6e10cbd8e42a (diff) | |
parent | 0a384a49d371838903d8401c5358ec60f3f4266d (diff) | |
download | ale-d2b0ae8108b2ee395d4eb43c49d68b322a023a30.zip |
Merge branch 'master' into sridhars
Diffstat (limited to 'test/command_callback')
107 files changed, 1527 insertions, 115 deletions
diff --git a/test/command_callback/ccls_paths/with_ccls-root/.ccls-root b/test/command_callback/ccls_paths/with_ccls-root/.ccls-root new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/ccls_paths/with_ccls-root/.ccls-root diff --git a/test/command_callback/ccls_paths/with_ccls/.ccls b/test/command_callback/ccls_paths/with_ccls/.ccls new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/ccls_paths/with_ccls/.ccls diff --git a/test/command_callback/ccls_paths/with_compile_commands_json/compile_commands.json b/test/command_callback/ccls_paths/with_compile_commands_json/compile_commands.json new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/ccls_paths/with_compile_commands_json/compile_commands.json diff --git a/test/command_callback/cquery_paths/with_compile_commands_json/compile_commands.json b/test/command_callback/cquery_paths/with_compile_commands_json/compile_commands.json new file mode 100644 index 00000000..e69de29b --- /dev/null +++ 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/elixir_paths/mix_project/lib/app.ex b/test/command_callback/elixir_paths/mix_project/lib/app.ex new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/elixir_paths/mix_project/lib/app.ex diff --git a/test/command_callback/elixir_paths/mix_project/mix.exs b/test/command_callback/elixir_paths/mix_project/mix.exs new file mode 100644 index 00000000..419685ae --- /dev/null +++ b/test/command_callback/elixir_paths/mix_project/mix.exs @@ -0,0 +1,3 @@ +defmodule Test.MixProject do + # fake mix project file +end diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app1/lib/app.ex b/test/command_callback/elixir_paths/umbrella_project/apps/app1/lib/app.ex new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/elixir_paths/umbrella_project/apps/app1/lib/app.ex diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app1/mix.exs b/test/command_callback/elixir_paths/umbrella_project/apps/app1/mix.exs new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/elixir_paths/umbrella_project/apps/app1/mix.exs diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app2/lib/app.ex b/test/command_callback/elixir_paths/umbrella_project/apps/app2/lib/app.ex new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/elixir_paths/umbrella_project/apps/app2/lib/app.ex diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app2/mix.exs b/test/command_callback/elixir_paths/umbrella_project/apps/app2/mix.exs new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/elixir_paths/umbrella_project/apps/app2/mix.exs diff --git a/test/command_callback/elixir_paths/umbrella_project/mix.exs b/test/command_callback/elixir_paths/umbrella_project/mix.exs new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/elixir_paths/umbrella_project/mix.exs diff --git a/test/command_callback/go_paths/go1/prj1/file.go b/test/command_callback/go_paths/go1/prj1/file.go new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/go_paths/go1/prj1/file.go diff --git a/test/command_callback/go_paths/go2/prj2/file.go b/test/command_callback/go_paths/go2/prj2/file.go new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/go_paths/go2/prj2/file.go diff --git a/test/command_callback/julia-languageserver-project/REQUIRE b/test/command_callback/julia-languageserver-project/REQUIRE new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/julia-languageserver-project/REQUIRE diff --git a/test/command_callback/julia-languageserver-project/test.jl b/test/command_callback/julia-languageserver-project/test.jl new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/julia-languageserver-project/test.jl diff --git a/test/command_callback/mix_paths/wrapped_project/mix.exs b/test/command_callback/mix_paths/wrapped_project/mix.exs deleted file mode 100644 index d2d855e6..00000000 --- a/test/command_callback/mix_paths/wrapped_project/mix.exs +++ /dev/null @@ -1 +0,0 @@ -use Mix.Config diff --git a/test/command_callback/psalm-project/vendor/bin/psalm-language-server b/test/command_callback/psalm-project/vendor/bin/psalm-language-server new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/psalm-project/vendor/bin/psalm-language-server diff --git a/test/command_callback/stack_build_paths/stack.yaml b/test/command_callback/stack_build_paths/stack.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/stack_build_paths/stack.yaml diff --git a/test/command_callback/stack_ghc_paths/stack.yaml b/test/command_callback/stack_ghc_paths/stack.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/stack_ghc_paths/stack.yaml diff --git a/test/command_callback/test_ada_gcc_command_callbacks.vader b/test/command_callback/test_ada_gcc_command_callbacks.vader new file mode 100644 index 00000000..de6e355e --- /dev/null +++ b/test/command_callback/test_ada_gcc_command_callbacks.vader @@ -0,0 +1,44 @@ +Before: + call ale#assert#SetUpLinterTest('ada', 'gcc') + call ale#test#SetFilename('dummy.adb') + + function! GetOutputDir(command) abort + let l:split_command = split(a:command) + let l:index = index(l:split_command, '-o') + return l:split_command[l:index + 1] + endfunction + + let b:out_file = GetOutputDir(ale_linters#ada#gcc#GetCommand(bufnr(''))) + +After: + delfunction GetOutputDir + + unlet! b:out_file + + call ale#assert#TearDownLinterTest() + +Execute(The executable should be configurable): + + AssertLinter 'gcc', + \ ale#Escape('gcc') . ' -x ada -c -gnatc' + \ . ' -o ' . b:out_file + \ . ' -I ' . ale#Escape(getcwd()) + \ . ' -gnatwa -gnatq %t' + + let b:ale_ada_gcc_executable = 'foo' + + AssertLinter 'foo', + \ ale#Escape('foo') . ' -x ada -c -gnatc' + \ . ' -o ' . b:out_file + \ . ' -I ' . ale#Escape(getcwd()) + \ . ' -gnatwa -gnatq %t' + +Execute(The options should be configurable): + + let g:ale_ada_gcc_options = '--foo --bar' + + AssertLinter 'gcc', + \ ale#Escape('gcc') . ' -x ada -c -gnatc' + \ . ' -o ' . b:out_file + \ . ' -I ' . ale#Escape(getcwd()) + \ . ' --foo --bar %t' diff --git a/test/command_callback/test_ansible_lint_command_callback.vader b/test/command_callback/test_ansible_lint_command_callback.vader new file mode 100644 index 00000000..ddc6c6c8 --- /dev/null +++ b/test/command_callback/test_ansible_lint_command_callback.vader @@ -0,0 +1,17 @@ +Before: + call ale#assert#SetUpLinterTest('ansible', 'ansible_lint') + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + +After: + unlet! b:bin_dir + unlet! b:executable + call ale#assert#TearDownLinterTest() + +Execute(The ansible_lint command callback should return default string): + AssertLinter 'ansible-lint', ale#Escape('ansible-lint') . ' -p %t' + +Execute(The ansible_lint executable should be configurable): + let g:ale_ansible_ansible_lint_executable = '~/.local/bin/ansible-lint' + + AssertLinter '~/.local/bin/ansible-lint', + \ ale#Escape('~/.local/bin/ansible-lint') . ' -p %t' diff --git a/test/command_callback/test_brakeman_command_callback.vader b/test/command_callback/test_brakeman_command_callback.vader index 61be4caf..15dbbe1c 100644 --- a/test/command_callback/test_brakeman_command_callback.vader +++ b/test/command_callback/test_brakeman_command_callback.vader @@ -12,7 +12,8 @@ Execute(The brakeman command callback should detect absence of a valid Rails app Execute(The brakeman command callback should find a valid Rails app root): call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb') - AssertLinter 'brakeman', 'brakeman -f json -q -p ' + AssertLinter 'brakeman', ale#Escape('brakeman') + \ . ' -f json -q -p ' \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app')) Execute(The brakeman command callback should include configured options): @@ -20,5 +21,17 @@ Execute(The brakeman command callback should include configured options): let g:ale_ruby_brakeman_options = '--combobulate' - AssertLinter 'brakeman', 'brakeman -f json -q --combobulate -p ' + AssertLinter 'brakeman', ale#Escape('brakeman') + \ . ' -f json -q --combobulate -p ' + \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app')) + +Execute(Setting bundle appends 'exec brakeman'): + call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb') + + let g:ale_ruby_brakeman_executable = 'bundle' + let g:ale_ruby_brakeman_options = '--combobulate' + + AssertLinter 'bundle', ale#Escape('bundle') + \ . ' exec brakeman' + \ . ' -f json -q --combobulate -p ' \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app')) diff --git a/test/command_callback/test_c_ccls_command_callbacks.vader b/test/command_callback/test_c_ccls_command_callbacks.vader new file mode 100644 index 00000000..b8f3ab5b --- /dev/null +++ b/test/command_callback/test_c_ccls_command_callbacks.vader @@ -0,0 +1,43 @@ +" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk> +" Description: A language server for C + +Before: + call ale#assert#SetUpLinterTest('c', 'ccls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .ccls file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls') + +Execute(The project root should be detected correctly using .ccls-root file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls-root/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls-root') + +Execute(The executable should be configurable): + AssertLinter 'ccls', ale#Escape('ccls') + + let b:ale_c_ccls_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(The initialization options should be configurable): + AssertLSPOptions {} + + let b:ale_c_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } + + AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } diff --git a/test/command_callback/test_c_clang_command_callbacks.vader b/test/command_callback/test_c_clang_command_callbacks.vader index 87f7fd06..7d2ff0bf 100644 --- a/test/command_callback/test_c_clang_command_callbacks.vader +++ b/test/command_callback/test_c_clang_command_callbacks.vader @@ -1,4 +1,7 @@ Before: + Save g:ale_c_parse_makefile + let g:ale_c_parse_makefile = 0 + call ale#assert#SetUpLinterTest('c', 'clang') let b:command_tail = ' -S -x c -fsyntax-only -iquote' \ . ' ' . ale#Escape(getcwd()) 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 582d4798..f78d0ea7 100644 --- a/test/command_callback/test_c_clang_tidy_command_callback.vader +++ b/test/command_callback/test_c_clang_tidy_command_callback.vader @@ -7,7 +7,7 @@ After: Execute(The clangtidy command default should be correct): AssertLinter 'clang-tidy', - \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s' + \ ale#Escape('clang-tidy') . ' %s' Execute(You should be able to remove the -checks option for clang-tidy): let b:ale_c_clangtidy_checks = [] @@ -23,12 +23,14 @@ Execute(You should be able to set other checks for clang-tidy): \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s' Execute(You should be able to manually set compiler flags for clang-tidy): + let b:ale_c_clangtidy_checks = ['*'] let b:ale_c_clangtidy_options = '-Wall' AssertLinter 'clang-tidy', \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall' Execute(The build directory should be configurable): + let b:ale_c_clangtidy_checks = ['*'] let b:ale_c_build_dir = '/foo/bar' AssertLinter 'clang-tidy', @@ -37,6 +39,7 @@ Execute(The build directory should be configurable): \ . ' -p ' . ale#Escape('/foo/bar') Execute(The build directory setting should override the options): + let b:ale_c_clangtidy_checks = ['*'] let b:ale_c_build_dir = '/foo/bar' let b:ale_c_clangtidy_options = '-Wall' @@ -48,6 +51,7 @@ Execute(The build directory setting should override the options): Execute(The build directory should be ignored for header files): call ale#test#SetFilename('test.h') + let b:ale_c_clangtidy_checks = ['*'] let b:ale_c_build_dir = '/foo/bar' let b:ale_c_clangtidy_options = '-Wall' @@ -61,6 +65,7 @@ Execute(The build directory should be ignored for header files): \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall' Execute(The executable should be configurable): + let b:ale_c_clangtidy_checks = ['*'] let b:ale_c_clangtidy_executable = 'foobar' AssertLinter 'foobar', diff --git a/test/command_callback/test_c_cppcheck_command_callbacks.vader b/test/command_callback/test_c_cppcheck_command_callbacks.vader index 3fc87a79..3ae4bdbe 100644 --- a/test/command_callback/test_c_cppcheck_command_callbacks.vader +++ b/test/command_callback/test_c_cppcheck_command_callbacks.vader @@ -19,6 +19,6 @@ Execute(cppcheck for C++ should detect compile_commands.json files): call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') AssertLinter 'cppcheck', - \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && ' + \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ale#Escape('cppcheck') \ . ' -q --language=c --project=compile_commands.json --enable=style %t' 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_gcc_command_callbacks.vader b/test/command_callback/test_c_gcc_command_callbacks.vader index 45514051..1f51c3bc 100644 --- a/test/command_callback/test_c_gcc_command_callbacks.vader +++ b/test/command_callback/test_c_gcc_command_callbacks.vader @@ -1,4 +1,7 @@ Before: + Save g:ale_c_parse_makefile + let g:ale_c_parse_makefile = 0 + call ale#assert#SetUpLinterTest('c', 'gcc') let b:command_tail = ' -S -x c -fsyntax-only -iquote' 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..0b5fac40 --- /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') + \ . ' %s ' + \ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/json_project/build')) diff --git a/test/command_callback/test_cargo_command_callbacks.vader b/test/command_callback/test_cargo_command_callbacks.vader index ac8846b0..f0afbc91 100644 --- a/test/command_callback/test_cargo_command_callbacks.vader +++ b/test/command_callback/test_cargo_command_callbacks.vader @@ -128,3 +128,27 @@ Execute(When a crate belongs to a workspace we chdir into the crate, unless we d \ 'cargo --version', \ 'cargo check --frozen --message-format=json -q', \] + +Execute(When ale_rust_cargo_use_clippy is set, cargo-clippy is used as linter): + let b:ale_rust_cargo_use_clippy = 1 + AssertLinter '', [ + \ 'cargo --version', + \ 'cargo clippy --frozen --message-format=json -q ', + \] + +Execute(When ale_rust_cargo_clippy_options is set, cargo-clippy appends it to commandline): + let b:ale_rust_cargo_use_clippy = 1 + let b:ale_rust_cargo_clippy_options = '-- -D warnings' + AssertLinter '', [ + \ 'cargo --version', + \ 'cargo clippy --frozen --message-format=json -q -- -D warnings', + \] + +Execute(cargo-check does not refer ale_rust_cargo_clippy_options): + let b:ale_rust_cargo_use_clippy = 0 + let b:ale_rust_cargo_use_check = 1 + let b:ale_rust_cargo_clippy_options = '-- -D warnings' + AssertLinter '', [ + \ 'cargo --version', + \ 'cargo check --frozen --message-format=json -q', + \] diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader index f28609ee..3297a4cb 100644 --- a/test/command_callback/test_clang_tidy_command_callback.vader +++ b/test/command_callback/test_clang_tidy_command_callback.vader @@ -7,12 +7,13 @@ After: Execute(The clangtidy command default should be correct): AssertLinter 'clang-tidy', - \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s' + \ ale#Escape('clang-tidy') . ' %s' Execute(You should be able to remove the -checks option for clang-tidy): let b:ale_cpp_clangtidy_checks = [] - AssertLinter 'clang-tidy', ale#Escape('clang-tidy') . ' %s' + AssertLinter 'clang-tidy', + \ ale#Escape('clang-tidy') . ' %s' Execute(You should be able to set other checks for clang-tidy): let b:ale_cpp_clangtidy_checks = ['-*', 'clang-analyzer-*'] @@ -22,34 +23,41 @@ Execute(You should be able to set other checks for clang-tidy): \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s' Execute(You should be able to manually set compiler flags for clang-tidy): + let b:ale_cpp_clangtidy_checks = ['*'] let b:ale_cpp_clangtidy_options = '-Wall' AssertLinter 'clang-tidy', \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall' - \ + Execute(The build directory should be configurable): + let b:ale_cpp_clangtidy_checks = ['*'] let b:ale_c_build_dir = '/foo/bar' AssertLinter 'clang-tidy', \ ale#Escape('clang-tidy') - \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar') + \ . ' -checks=' . ale#Escape('*') . ' %s' + \ . ' -p ' . ale#Escape('/foo/bar') Execute(The build directory setting should override the options): + let b:ale_cpp_clangtidy_checks = ['*'] let b:ale_c_build_dir = '/foo/bar' let b:ale_cpp_clangtidy_options = '-Wall' AssertLinter 'clang-tidy', \ ale#Escape('clang-tidy') - \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar') + \ . ' -checks=' . ale#Escape('*') . ' %s' + \ . ' -p ' . ale#Escape('/foo/bar') Execute(The build directory should be ignored for header files): call ale#test#SetFilename('test.h') + let b:ale_cpp_clangtidy_checks = ['*'] let b:ale_c_build_dir = '/foo/bar' let b:ale_cpp_clangtidy_options = '-Wall' AssertLinter 'clang-tidy', - \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall' + \ ale#Escape('clang-tidy') + \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall' call ale#test#SetFilename('test.hpp') @@ -57,6 +65,7 @@ Execute(The build directory should be ignored for header files): \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall' Execute(The executable should be configurable): + let b:ale_cpp_clangtidy_checks = ['*'] let b:ale_cpp_clangtidy_executable = 'foobar' AssertLinter 'foobar', diff --git a/test/command_callback/test_cpp_ccls_command_callbacks.vader b/test/command_callback/test_cpp_ccls_command_callbacks.vader new file mode 100644 index 00000000..38947acf --- /dev/null +++ b/test/command_callback/test_cpp_ccls_command_callbacks.vader @@ -0,0 +1,43 @@ +" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk> +" Description: A language server for C++ + +Before: + call ale#assert#SetUpLinterTest('cpp', 'ccls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .ccls file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls') + +Execute(The project root should be detected correctly using .ccls-root file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls-root/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls-root') + +Execute(The executable should be configurable): + AssertLinter 'ccls', ale#Escape('ccls') + + let b:ale_cpp_ccls_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(The initialization options should be configurable): + AssertLSPOptions {} + + let b:ale_cpp_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } + + AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } diff --git a/test/command_callback/test_cpp_clang_command_callbacks.vader b/test/command_callback/test_cpp_clang_command_callbacks.vader index 3a5ea945..e96fd8e7 100644 --- a/test/command_callback/test_cpp_clang_command_callbacks.vader +++ b/test/command_callback/test_cpp_clang_command_callbacks.vader @@ -1,4 +1,7 @@ Before: + Save g:ale_c_parse_makefile + let g:ale_c_parse_makefile = 0 + call ale#assert#SetUpLinterTest('cpp', 'clang') let b:command_tail = ' -S -x c++ -fsyntax-only -iquote' \ . ' ' . ale#Escape(getcwd()) diff --git a/test/command_callback/test_cpp_clazy_command_callback.vader b/test/command_callback/test_cpp_clazy_command_callback.vader new file mode 100644 index 00000000..1be43b96 --- /dev/null +++ b/test/command_callback/test_cpp_clazy_command_callback.vader @@ -0,0 +1,54 @@ +Before: + call ale#assert#SetUpLinterTest('cpp', 'clazy') + call ale#test#SetFilename('test.cpp') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The clazy command default should be correct): + AssertLinter 'clazy-standalone', + \ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' %s' + +Execute(You should be able to remove the -checks option for clazy-standalone): + let b:ale_cpp_clazy_checks = [] + + AssertLinter 'clazy-standalone', ale#Escape('clazy-standalone') . ' %s' + +Execute(You should be able to set other checks for clazy-standalone): + let b:ale_cpp_clazy_checks = ['level2', 'level3'] + + AssertLinter 'clazy-standalone', + \ ale#Escape('clazy-standalone') + \ . ' -checks=' . ale#Escape('level2,level3') . ' %s' + +Execute(You should be able to manually set compiler flags for clazy-standalone): + let b:ale_cpp_clazy_options = '-qt4-compat' + + AssertLinter 'clazy-standalone', + \ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' -qt4-compat' . ' %s' + \ +Execute(The build directory should be configurable): + let b:ale_c_build_dir = '/foo/bar' + + AssertLinter 'clazy-standalone', + \ ale#Escape('clazy-standalone') + \ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s' + +Execute(The build directory should be ignored for header files): + call ale#test#SetFilename('test.h') + + let b:ale_c_build_dir = '/foo/bar' + + AssertLinter 'clazy-standalone', + \ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' %s' + + call ale#test#SetFilename('test.hpp') + + AssertLinter 'clazy-standalone', + \ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' %s' + +Execute(The executable should be configurable): + let b:ale_cpp_clazy_executable = 'foobar' + + AssertLinter 'foobar', + \ ale#Escape('foobar') . ' -checks=' . ale#Escape('level1') . ' %s' diff --git a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader index 3a7ada2c..352c88d5 100644 --- a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader +++ b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader @@ -17,6 +17,6 @@ Execute(cppcheck for C++ should detect compile_commands.json files): call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') AssertLinter 'cppcheck', - \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && ' + \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ale#Escape('cppcheck') \ . ' -q --language=c++ --project=compile_commands.json --enable=style %t' 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_cpp_gcc_command_callbacks.vader b/test/command_callback/test_cpp_gcc_command_callbacks.vader index f9fad8c8..0a86df4f 100644 --- a/test/command_callback/test_cpp_gcc_command_callbacks.vader +++ b/test/command_callback/test_cpp_gcc_command_callbacks.vader @@ -1,4 +1,7 @@ Before: + Save g:ale_c_parse_makefile + let g:ale_c_parse_makefile = 0 + call ale#assert#SetUpLinterTest('cpp', 'gcc') let b:command_tail = ' -S -x c++ -fsyntax-only -iquote' \ . ' ' . ale#Escape(getcwd()) diff --git a/test/command_callback/test_cs_mcsc_command_callbacks.vader b/test/command_callback/test_cs_mcsc_command_callbacks.vader index 20ddb28b..d15898e0 100644 --- a/test/command_callback/test_cs_mcsc_command_callbacks.vader +++ b/test/command_callback/test_cs_mcsc_command_callbacks.vader @@ -5,43 +5,43 @@ After: call ale#assert#TearDownLinterTest() Execute(The mcsc linter should return the correct default command): - AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && ' + AssertLinter 'mcs', ale#path#CdString(g:dir) \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs') Execute(The options should be be used in the command): let g:ale_cs_mcsc_options = '-pkg:dotnet' - AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && ' + AssertLinter 'mcs', ale#path#CdString(g:dir) \ . 'mcs -unsafe -pkg:dotnet -out:TEMP -t:module -recurse:' . ale#Escape('*.cs') Execute(The souce path should be be used in the command): let g:ale_cs_mcsc_source = '../foo/bar' - AssertLinter 'mcs', 'cd ' . ale#Escape('../foo/bar') . ' && ' + AssertLinter 'mcs', ale#path#CdString('../foo/bar') \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs') Execute(The list of search pathes for assemblies should be be used in the command if not empty): let g:ale_cs_mcsc_assembly_path = ['/usr/lib/mono', '../foo/bar'] - AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && ' + AssertLinter 'mcs', ale#path#CdString(g:dir) \ . 'mcs -unsafe' \ . ' -lib:' . ale#Escape('/usr/lib/mono') . ',' . ale#Escape('../foo/bar') \ . ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs') let g:ale_cs_mcsc_assembly_path = [] - AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && ' + AssertLinter 'mcs', ale#path#CdString(g:dir) \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs') Execute(The list of assemblies should be be used in the command if not empty): let g:ale_cs_mcsc_assemblies = ['foo.dll', 'bar.dll'] - AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && ' + AssertLinter 'mcs', ale#path#CdString(g:dir) \ . 'mcs -unsafe' \ . ' -r:' . ale#Escape('foo.dll') . ',' . ale#Escape('bar.dll') \ . ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs') let g:ale_cs_mcsc_assemblies = [] - AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && ' + AssertLinter 'mcs', ale#path#CdString(g:dir) \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs') 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_d_dls_callbacks.vader b/test/command_callback/test_d_dls_callbacks.vader new file mode 100644 index 00000000..156ebf66 --- /dev/null +++ b/test/command_callback/test_d_dls_callbacks.vader @@ -0,0 +1,19 @@ +Before: + call ale#assert#SetUpLinterTest('d', 'dls') + + Save &filetype + let &filetype = 'd' + +After: + call ale#assert#TearDownLinterTest() + +Execute(The language string should be correct): + AssertLSPLanguage 'd' + +Execute(The default executable should be correct): + AssertLinter 'dls', 'dls' + +Execute(The executable should be configurable): + let g:ale_d_dls_executable = 'foobar' + + AssertLinter 'foobar', 'foobar' diff --git a/test/command_callback/test_dart_language_server_command_callback.vader b/test/command_callback/test_dart_language_server_command_callback.vader new file mode 100644 index 00000000..5567f271 --- /dev/null +++ b/test/command_callback/test_dart_language_server_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('dart', 'language_server') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'dart_language_server', ale#Escape('dart_language_server') diff --git a/test/command_callback/test_dockerfile_lint_command_callback.vader b/test/command_callback/test_dockerfile_lint_command_callback.vader new file mode 100644 index 00000000..abc32e0d --- /dev/null +++ b/test/command_callback/test_dockerfile_lint_command_callback.vader @@ -0,0 +1,19 @@ +Before: + call ale#assert#SetUpLinterTest('dockerfile', 'dockerfile_lint') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'dockerfile_lint', ale#Escape('dockerfile_lint') . ' -p -j -f %t' + +Execute(The executable should be configurable): + let b:ale_dockerfile_dockerfile_lint_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') . ' -p -j -f %t' + +Execute(The options should be configurable): + let b:ale_dockerfile_dockerfile_lint_options = '-r additional.yaml' + + AssertLinter 'dockerfile_lint', ale#Escape('dockerfile_lint') . ' -r additional.yaml -p -j -f %t' + diff --git a/test/command_callback/test_elixir_ls_command_callbacks.vader b/test/command_callback/test_elixir_ls_command_callbacks.vader new file mode 100644 index 00000000..ca785054 --- /dev/null +++ b/test/command_callback/test_elixir_ls_command_callbacks.vader @@ -0,0 +1,35 @@ +Before: + call ale#assert#SetUpLinterTest('elixir', 'elixir_ls') + + let g:ale_has_override['win32'] = 0 + +After: + let g:ale_has_override = {} + + call ale#assert#TearDownLinterTest() + +Execute(should set correct defaults (unix)): + AssertLinter 'elixir-ls/language_server.sh', 'elixir-ls/language_server.sh' + +Execute(should set correct defaults (win32)): + let g:ale_has_override['win32'] = 1 + + AssertLinter 'elixir-ls\language_server.bat', 'elixir-ls\language_server.bat' + +Execute(should configure elixir-ls release location): + let b:ale_elixir_elixir_ls_release = 'boo' + + AssertLinter 'boo/language_server.sh', 'boo/language_server.sh' + +Execute(should set correct LSP values): + call ale#test#SetFilename('elixir_paths/umbrella_project/apps/app1/lib/app.ex') + + AssertLSPLanguage 'elixir' + AssertLSPOptions {} + AssertLSPConfig {} + AssertLSPProject ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project') + +Execute(should accept configuration settings): + AssertLSPConfig {} + let b:ale_elixir_elixir_ls_config = {'elixirLS': {'dialyzerEnabled': v:false}} + AssertLSPConfig {'elixirLS': {'dialyzerEnabled': v:false}} diff --git a/test/command_callback/test_elixir_mix_command_callbacks.vader b/test/command_callback/test_elixir_mix_command_callbacks.vader index 18fb13ed..b0d0af98 100644 --- a/test/command_callback/test_elixir_mix_command_callbacks.vader +++ b/test/command_callback/test_elixir_mix_command_callbacks.vader @@ -11,9 +11,23 @@ After: call ale#assert#TearDownLinterTest() Execute(The default mix command should be correct): - call ale#test#SetFilename('mix_paths/wrapped_project/lib/app.ex') + call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex') AssertLinter 'mix', - \ ale#path#CdString(ale#path#Simplify(g:dir . '/mix_paths/wrapped_project')) + \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project')) \ . g:env_prefix \ . 'mix compile %s' + +Execute(FindMixProjectRoot should detect the project root directory via mix.exs): + silent execute 'file ' . fnameescape(g:dir . '/elixir_paths/mix_project/lib/app.ex') + + AssertEqual + \ ale#path#Simplify(g:dir . '/elixir_paths/mix_project'), + \ ale#handlers#elixir#FindMixProjectRoot(bufnr('')) + +Execute(FindMixUmbrellaRoot should detect the umbrella root directory via mix.exs): + silent execute 'file ' . fnameescape(g:dir . '/elixir_paths/umbrella_project/apps/app1/lib/app.ex') + + AssertEqual + \ ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project'), + \ ale#handlers#elixir#FindMixUmbrellaRoot(bufnr('')) 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_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader index f12b6747..ede511e0 100644 --- a/test/command_callback/test_flake8_command_callback.vader +++ b/test/command_callback/test_flake8_command_callback.vader @@ -1,5 +1,6 @@ Before: call ale#assert#SetUpLinterTest('python', 'flake8') + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' WithChainResults ['3.0.0'] @@ -152,8 +153,16 @@ Execute(Using `python -m flake8` should be supported for running flake8): Execute(Setting executable to 'pipenv' should append 'run flake8'): let g:ale_python_flake8_executable = 'path/to/pipenv' - " FIXME: pipenv should check the vresion with flake8. + " FIXME: pipenv should check the version with flake8. WithChainResults [] AssertLinter 'path/to/pipenv', \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('path/to/pipenv') . ' run flake8 --format=default -' + +Execute(Pipenv is detected when python_flake8_auto_pipenv is set): + let g:ale_python_flake8_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -' 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_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader index 86113728..c6e324f2 100644 --- a/test/command_callback/test_gobuild_command_callback.vader +++ b/test/command_callback/test_gobuild_command_callback.vader @@ -1,36 +1,31 @@ Before: - call ale#assert#SetUpLinterTest('go', 'gobuild') + Save g:ale_go_go_executable - let g:env_prefix = has('win32') - \ ? 'set GOPATH=' . ale#Escape('/foo/bar') . ' && ' - \ : 'GOPATH=' . ale#Escape('/foo/bar') . ' ' - call ale_linters#go#gobuild#ResetEnv() + call ale#assert#SetUpLinterTest('go', 'gobuild') WithChainResults ['/foo/bar', '/foo/baz'] After: - unlet! g:env_prefix + Restore call ale#assert#TearDownLinterTest() Execute(The default commands should be correct): - AssertLinter 'go', [ - \ 'go env GOPATH GOROOT', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' - \ . 'go test -c -o /dev/null ./' - \] - - " We shouldn't run `go env` many times after we've got it. - AssertLinter 'go', [ - \ '', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + AssertLinter 'go', + \ ale#path#CdString(expand('%:p:h')) \ . 'go test -c -o /dev/null ./' - \] Execute(Extra options should be supported): let g:ale_go_gobuild_options = '--foo-bar' - AssertLinter 'go', [ - \ 'go env GOPATH GOROOT', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + AssertLinter 'go', + \ ale#path#CdString(expand('%:p:h')) \ . 'go test --foo-bar -c -o /dev/null ./' - \] + + let g:ale_go_gobuild_options = '' + +Execute(The executable should be configurable): + let g:ale_go_go_executable = 'foobar' + + AssertLinter 'foobar', + \ ale#path#CdString(expand('%:p:h')) + \ . 'foobar test -c -o /dev/null ./' diff --git a/test/command_callback/test_golangci_lint_command_callback.vader b/test/command_callback/test_golangci_lint_command_callback.vader new file mode 100644 index 00000000..345f58b1 --- /dev/null +++ b/test/command_callback/test_golangci_lint_command_callback.vader @@ -0,0 +1,38 @@ +Before: + call ale#assert#SetUpLinterTest('go', 'golangci_lint') + call ale#test#SetFilename('test.go') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The golangci-lint defaults should be correct): + AssertLinter 'golangci-lint', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Escape('golangci-lint') + \ . ' run ' . ale#Escape(expand('%' . ':t')) + \ . ' --enable-all' + +Execute(The golangci-lint callback should use a configured executable): + let b:ale_go_golangci_lint_executable = 'something else' + + AssertLinter 'something else', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Escape('something else') + \ . ' run ' . ale#Escape(expand('%' . ':t')) + \ . ' --enable-all' + +Execute(The golangci-lint callback should use configured options): + let b:ale_go_golangci_lint_options = '--foobar' + + AssertLinter 'golangci-lint', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Escape('golangci-lint') + \ . ' run ' . ale#Escape(expand('%' . ':t')) + \ . ' --foobar' + +Execute(The golangci-lint `lint_package` option should use the correct command): + let b:ale_go_golangci_lint_package = 1 + + AssertLinter 'golangci-lint', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Escape('golangci-lint') . ' run --enable-all' diff --git a/test/command_callback/test_golangserver_command_callback.vader b/test/command_callback/test_golangserver_command_callback.vader new file mode 100644 index 00000000..90fdc26f --- /dev/null +++ b/test/command_callback/test_golangserver_command_callback.vader @@ -0,0 +1,68 @@ +Before: + Save $GOPATH + Save g:ale_completion_enabled + + let g:ale_completion_enabled = 0 + let g:sep = has('win32') ? ';' : ':' + + call ale#assert#SetUpLinterTest('go', 'langserver') + let $GOPATH = ale#path#Simplify(g:dir . '/go_paths/go1') + \ . g:sep + \ . ale#path#Simplify(g:dir . '/go_paths/go2') + +After: + Restore + + unlet! b:ale_completion_enabled + unlet! g:sep + + call ale#assert#TearDownLinterTest() + +Execute(should set correct defaults): + AssertLinter 'go-langserver', ale#Escape('go-langserver') + +Execute(should configure go-langserver callback executable): + let b:ale_go_langserver_executable = 'boo' + + AssertLinter 'boo', ale#Escape('boo') + +Execute(should set go-langserver options): + call ale#test#SetFilename('go_paths/go1/prj1/file.go') + let b:ale_completion_enabled = 1 + let b:ale_go_langserver_options = '' + + AssertLinter 'go-langserver', + \ ale#Escape('go-langserver') . ' -gocodecompletion' + + let b:ale_go_langserver_options = '-trace' + + AssertLinter 'go-langserver', + \ ale#Escape('go-langserver') . ' -gocodecompletion -trace' + +Execute(should ignore go-langserver -gocodecompletion option): + call ale#test#SetFilename('go_paths/go1/prj1/file.go') + + let b:ale_go_langserver_options = '-trace -gocodecompletion' + let b:ale_completion_enabled = 1 + + AssertLinter 'go-langserver', + \ ale#Escape('go-langserver') . ' -gocodecompletion -trace' + + let b:ale_completion_enabled = 0 + + AssertLinter 'go-langserver', ale#Escape('go-langserver') . ' -trace' + +Execute(should set go-langserver for go app1): + call ale#test#SetFilename('go_paths/go1/prj1/file.go') + + AssertLSPLanguage 'go' + AssertLSPConfig {} + AssertLSPProject ale#path#Simplify(g:dir . '/go_paths/go1') + +Execute(should set go-langserver for go app2): + call ale#test#SetFilename('go_paths/go2/prj1/file.go') + + AssertLSPLanguage 'go' + AssertLSPOptions {} + AssertLSPConfig {} + AssertLSPProject ale#path#Simplify(g:dir . '/go_paths/go2') diff --git a/test/command_callback/test_golint_command_callbacks.vader b/test/command_callback/test_golint_command_callbacks.vader new file mode 100644 index 00000000..7c300309 --- /dev/null +++ b/test/command_callback/test_golint_command_callbacks.vader @@ -0,0 +1,18 @@ +Before: + call ale#assert#SetUpLinterTest('go', 'golint') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default golint command should be correct): + AssertLinter 'golint', ale#Escape('golint') . ' %t' + +Execute(The golint executable should be configurable): + let b:ale_go_golint_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') . ' %t' + +Execute(The golint options should be configurable): + let b:ale_go_golint_options = '--foo' + + AssertLinter 'golint', ale#Escape('golint') . ' --foo %t' diff --git a/test/command_callback/test_gometalinter_command_callback.vader b/test/command_callback/test_gometalinter_command_callback.vader index d788c5bd..88e86801 100644 --- a/test/command_callback/test_gometalinter_command_callback.vader +++ b/test/command_callback/test_gometalinter_command_callback.vader @@ -7,7 +7,7 @@ After: Execute(The gometalinter defaults should be correct): AssertLinter 'gometalinter', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('gometalinter') \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' .' @@ -16,7 +16,7 @@ Execute(The gometalinter callback should use a configured executable): let b:ale_go_gometalinter_executable = 'something else' AssertLinter 'something else', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('something else') \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' .' @@ -25,7 +25,7 @@ Execute(The gometalinter callback should use configured options): let b:ale_go_gometalinter_options = '--foobar' AssertLinter 'gometalinter', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('gometalinter') \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' --foobar' . ' .' @@ -34,5 +34,5 @@ Execute(The gometalinter `lint_package` option should use the correct command): let b:ale_go_gometalinter_lint_package = 1 AssertLinter 'gometalinter', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('gometalinter') . ' .' diff --git a/test/command_callback/test_gosimple_command_callback.vader b/test/command_callback/test_gosimple_command_callback.vader index 7b8c66ae..59013df0 100644 --- a/test/command_callback/test_gosimple_command_callback.vader +++ b/test/command_callback/test_gosimple_command_callback.vader @@ -7,4 +7,4 @@ After: Execute(The default gosimple command should be correct): AssertLinter 'gosimple', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && gosimple .' + \ ale#path#CdString(expand('%:p:h')) . ' gosimple .' diff --git a/test/command_callback/test_gotype_command_callback.vader b/test/command_callback/test_gotype_command_callback.vader index da9ceaf3..1898a0cb 100644 --- a/test/command_callback/test_gotype_command_callback.vader +++ b/test/command_callback/test_gotype_command_callback.vader @@ -7,7 +7,7 @@ After: Execute(The default gotype command should be correct): AssertLinter 'gotype', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && gotype .' + \ ale#path#CdString(expand('%:p:h')) . ' gotype .' Execute(The gotype callback should ignore test files): call ale#test#SetFilename('bla_test.go') diff --git a/test/command_callback/test_govet_command_callback.vader b/test/command_callback/test_govet_command_callback.vader index a73118ae..a55c0812 100644 --- a/test/command_callback/test_govet_command_callback.vader +++ b/test/command_callback/test_govet_command_callback.vader @@ -1,8 +1,19 @@ Before: + Save g:ale_go_go_executable + Save g:ale_go_govet_options call ale#assert#SetUpLinterTest('go', 'govet') After: + Restore call ale#assert#TearDownLinterTest() Execute(The default command should be correct): - AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet .' + AssertLinter 'go', ale#path#CdString(expand('%:p:h')) . ' go vet .' + +Execute(Extra options should be supported): + let g:ale_go_govet_options = '--foo-bar' + AssertLinter 'go', ale#path#CdString(expand('%:p:h')) . ' go vet --foo-bar .' + +Execute(The executable should be configurable): + let g:ale_go_go_executable = 'foobar' + AssertLinter 'foobar', ale#path#CdString(expand('%:p:h')) . ' foobar vet .' diff --git a/test/command_callback/test_haml_hamllint_command_callback.vader b/test/command_callback/test_haml_hamllint_command_callback.vader index a59446ca..694b21d3 100644 --- a/test/command_callback/test_haml_hamllint_command_callback.vader +++ b/test/command_callback/test_haml_hamllint_command_callback.vader @@ -35,3 +35,7 @@ Execute(The command should include a .rubocop.yml and a .haml-lint if both are f AssertLinter 'haml-lint', \ ale#Env('HAML_LINT_RUBOCOP_CONF', b:conf_rubocop) \ . 'haml-lint --config ' . ale#Escape(b:conf_hamllint) . ' %t' + +Execute(The executable can be overridden): + let b:ale_haml_hamllint_executable = 'bin/haml-lint' + AssertLinter 'bin/haml-lint', 'bin/haml-lint %t' diff --git a/test/command_callback/test_haskell_ghc_mod_command_callbacks.vader b/test/command_callback/test_haskell_ghc_mod_command_callbacks.vader new file mode 100644 index 00000000..c1cc8597 --- /dev/null +++ b/test/command_callback/test_haskell_ghc_mod_command_callbacks.vader @@ -0,0 +1,10 @@ +Before: + call ale#assert#SetUpLinterTest('haskell', 'ghc_mod') + +After: + call ale#assert#TearDownLinterTest() + +Execute(Default should use ghc-mod): + AssertLinter + \ 'ghc-mod', + \ ale#Escape('ghc-mod') . ' --map-file %s=%t check %s' 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_haskell_hlint_command_callbacks.vader b/test/command_callback/test_haskell_hlint_command_callbacks.vader new file mode 100644 index 00000000..6d227c9d --- /dev/null +++ b/test/command_callback/test_haskell_hlint_command_callbacks.vader @@ -0,0 +1,17 @@ +Before: + call ale#assert#SetUpLinterTest('haskell', 'hlint') + + let b:base_opts = '--color=never --json -' + +After: + unlet! b:base_opts + call ale#assert#TearDownLinterTest() + +Execute(executable should be configurable): + AssertLinter 'hlint', ale#Escape('hlint') . ' ' . b:base_opts + let b:ale_haskell_hlint_executable = 'myHlint' + AssertLinter 'myHlint', ale#Escape('myHlint') . ' ' . b:base_opts + +Execute(should accept options): + let b:ale_haskell_hlint_options= '-h myhlintfile.yaml' + AssertLinter 'hlint', ale#Escape('hlint') . ' -h myhlintfile.yaml ' . b:base_opts diff --git a/test/command_callback/test_haskell_stack_build_command_callback.vader b/test/command_callback/test_haskell_stack_build_command_callback.vader new file mode 100644 index 00000000..f1e6f755 --- /dev/null +++ b/test/command_callback/test_haskell_stack_build_command_callback.vader @@ -0,0 +1,13 @@ +Before: + call ale#assert#SetUpLinterTest('haskell', 'stack_build') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The linter should not be executed when there's no stack.yaml file): + AssertLinterNotExecuted + +Execute(The linter should be executed when there is a stack.yaml file): + call ale#test#SetFilename('stack_build_paths/test.hs') + + AssertLinter 'stack', 'stack build --fast' diff --git a/test/command_callback/test_haskell_stack_ghc_command_callback.vader b/test/command_callback/test_haskell_stack_ghc_command_callback.vader new file mode 100644 index 00000000..4adab583 --- /dev/null +++ b/test/command_callback/test_haskell_stack_ghc_command_callback.vader @@ -0,0 +1,14 @@ +Before: + call ale#assert#SetUpLinterTest('haskell', 'stack_ghc') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The linter should not be executed when there's no stack.yaml file): + AssertLinterNotExecuted + +Execute(The linter should be executed when there is a stack.yaml file): + call ale#test#SetFilename('stack_ghc_paths/test.hs') + + AssertLinter 'stack', 'stack ghc -- -fno-code -v0 %t' + diff --git a/test/command_callback/test_html_stylelint_command_callback.vader b/test/command_callback/test_html_stylelint_command_callback.vader new file mode 100644 index 00000000..49d7d143 --- /dev/null +++ b/test/command_callback/test_html_stylelint_command_callback.vader @@ -0,0 +1,60 @@ +Before: + Save g:ale_html_stylelint_executable + Save g:ale_html_stylelint_use_global + Save g:ale_html_stylelint_options + + unlet! b:executable + + unlet! g:ale_html_stylelint_executable + unlet! g:ale_html_stylelint_use_global + unlet! g:ale_html_stylelint_options + + call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetFilename('testfile.html') + + runtime ale_linters/html/stylelint.vim + +After: + Restore + + unlet! b:executable + unlet! b:ale_html_stylelint_executable + unlet! b:ale_html_stylelint_use_global + unlet! b:ale_html_stylelint_options + + call ale#test#SetFilename('test.txt') + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(node_modules directories should be discovered): + call ale#test#SetFilename('stylelint_paths/nested/testfile.html') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/stylelint_paths/node_modules/.bin/stylelint' + \) + + AssertEqual b:executable, ale_linters#html#stylelint#GetExecutable(bufnr('')) + AssertEqual + \ ale#Escape(b:executable) . ' --stdin-filename %s', + \ ale_linters#html#stylelint#GetCommand(bufnr('')) + +Execute(The global override should work): + let b:ale_html_stylelint_executable = 'foobar' + let b:ale_html_stylelint_use_global = 1 + + call ale#test#SetFilename('stylelint_paths/nested/testfile.html') + + AssertEqual 'foobar', ale_linters#html#stylelint#GetExecutable(bufnr('')) + AssertEqual + \ ale#Escape('foobar') . ' --stdin-filename %s', + \ ale_linters#html#stylelint#GetCommand(bufnr('')) + +Execute(Extra options should be configurable): + let b:ale_html_stylelint_options = '--whatever' + + AssertEqual 'stylelint', ale_linters#html#stylelint#GetExecutable(bufnr('')) + AssertEqual + \ ale#Escape('stylelint') . ' --whatever --stdin-filename %s', + \ ale_linters#html#stylelint#GetCommand(bufnr('')) diff --git a/test/command_callback/test_ispc_ispc_command_callbacks.vader b/test/command_callback/test_ispc_ispc_command_callbacks.vader new file mode 100644 index 00000000..f1aeb2f8 --- /dev/null +++ b/test/command_callback/test_ispc_ispc_command_callbacks.vader @@ -0,0 +1,20 @@ +Before: + call ale#assert#SetUpLinterTest('ispc', 'ispc') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The executable should be configurable): + AssertLinter 'ispc', + \ ale#Escape('ispc') . ' --nowrap %s' + + let b:ale_ispc_ispc_executable = 'foo' + + AssertLinter 'foo', + \ ale#Escape('foo') . ' --nowrap %s' + +Execute(The options should be configurable): + let g:ale_ispc_ispc_options = '--foo' + + AssertLinter 'ispc', + \ ale#Escape('ispc') . ' --nowrap --foo' . ' %s' diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader index 07a0794a..2dcb6a1b 100644 --- a/test/command_callback/test_javac_command_callback.vader +++ b/test/command_callback/test_javac_command_callback.vader @@ -3,7 +3,7 @@ Before: call ale#test#SetFilename('dummy.java') let g:cp_sep = has('unix') ? ':' : ';' - let g:prefix = 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + let g:prefix = ale#path#CdString(expand('%:p:h')) \ . ale#Escape('javac') . ' -Xlint' function! GetCommand(previous_output) abort @@ -43,7 +43,7 @@ Execute(The executable should be configurable): let g:ale_java_javac_executable = 'foobar' AssertLinter 'foobar', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('foobar') . ' -Xlint' \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t' @@ -106,7 +106,7 @@ Execute(The javac callback should detect source directories): call ale#engine#InitBufferInfo(bufnr('')) AssertLinter 'javac', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' + \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' \ . ' -sourcepath ' . ale#Escape( \ ale#path#Simplify(g:dir . '/java_paths/src/main/java/') \ ) @@ -124,7 +124,7 @@ Execute(The javac callback should combine detected source directories and classp \ '/xyz/abc.jar', \] AssertLinter 'javac', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' + \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' \ . ' -cp ' . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep)) \ . ' -sourcepath ' . ale#Escape( \ ale#path#Simplify(g:dir . '/java_paths/src/main/java/') @@ -147,7 +147,7 @@ Execute(The javac callback should include src/test/java for test paths): call ale#engine#InitBufferInfo(bufnr('')) AssertLinter 'javac', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' + \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' \ . ' -sourcepath ' . ale#Escape(join([ \ ale#path#Simplify(g:dir . '/java_paths/src/main/java/'), \ ale#path#Simplify(g:dir . '/java_paths/src/test/java/'), @@ -160,7 +160,7 @@ Execute(The javac callback should include src/main/jaxb when available): call ale#engine#InitBufferInfo(bufnr('')) AssertLinter 'javac', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint' + \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' \ . ' -sourcepath ' . ale#Escape(join([ \ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/java/'), \ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/jaxb/'), diff --git a/test/command_callback/test_javalsp_command_callback.vader b/test/command_callback/test_javalsp_command_callback.vader new file mode 100644 index 00000000..1fbfddfb --- /dev/null +++ b/test/command_callback/test_javalsp_command_callback.vader @@ -0,0 +1,10 @@ + +Before: + call ale#assert#SetUpLinterTest('java', 'javalsp') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The javalsp callback should return the correct default value): + AssertLinter 'java', ale#Escape('java -cp javacs.jar -Xverify:none org.javacs.Main') + 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_jshint_command_callback.vader b/test/command_callback/test_jshint_command_callback.vader new file mode 100644 index 00000000..517c957c --- /dev/null +++ b/test/command_callback/test_jshint_command_callback.vader @@ -0,0 +1,17 @@ +Before: + Save g:ale_jshint_config_loc + + unlet! g:ale_jshint_config_loc + + call ale#assert#SetUpLinterTest('javascript', 'jshint') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'jshint', ale#Escape('jshint') . ' --reporter unix --extract auto --filename %s -' + +Execute(Setting a config location should add the config parameter): + let g:ale_jshint_config_loc = '/some/file' + + AssertLinter 'jshint', ale#Escape('jshint') . ' --reporter unix --extract auto --config ' . ale#Escape('/some/file') . ' --filename %s -' diff --git a/test/command_callback/test_julia_languageserver_callbacks.vader b/test/command_callback/test_julia_languageserver_callbacks.vader new file mode 100644 index 00000000..3bc46e3d --- /dev/null +++ b/test/command_callback/test_julia_languageserver_callbacks.vader @@ -0,0 +1,30 @@ +Before: + Save g:ale_julia_executable + + call ale#assert#SetUpLinterTest('julia', 'languageserver') + +After: + Restore + + call ale#assert#TearDownLinterTest() + +Execute(The default executable path should be correct): + AssertLinter 'julia', + \ ale#Escape('julia') . + \' --startup-file=no --history-file=no -e ' . + \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);') + +Execute(The executable should be configurable): + let g:ale_julia_executable = 'julia-new' + + AssertLinter 'julia-new', + \ ale#Escape('julia-new') . + \' --startup-file=no --history-file=no -e ' . + \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);') + +Execute(The project root should be detected correctly): + AssertLSPProject '' + + call ale#test#SetFilename('julia-languageserver-project/test.jl') + + AssertLSPProject ale#path#Simplify(g:dir . '/julia-languageserver-project') diff --git a/test/command_callback/test_kotlin_languageserver_command_callback.vader b/test/command_callback/test_kotlin_languageserver_command_callback.vader new file mode 100644 index 00000000..e83a4f37 --- /dev/null +++ b/test/command_callback/test_kotlin_languageserver_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('kotlin', 'languageserver') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'kotlin-language-server', ale#Escape('kotlin-language-server') diff --git a/test/command_callback/test_lintr_command_callback.vader b/test/command_callback/test_lintr_command_callback.vader index 8a0e6c1c..187d3875 100644 --- a/test/command_callback/test_lintr_command_callback.vader +++ b/test/command_callback/test_lintr_command_callback.vader @@ -6,7 +6,7 @@ After: Execute(The default lintr command should be correct): AssertLinter 'Rscript', - \ 'cd ' . ale#Escape(getcwd()) . ' && ' + \ ale#path#CdString(getcwd()) \ . 'Rscript --vanilla -e ' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . 'lint(cache = FALSE, commandArgs(TRUE), ' @@ -17,7 +17,7 @@ Execute(The lintr options should be configurable): let b:ale_r_lintr_options = 'with_defaults(object_usage_linter = NULL)' AssertLinter 'Rscript', - \ 'cd ' . ale#Escape(getcwd()) . ' && ' + \ ale#path#CdString(getcwd()) \ . 'Rscript --vanilla -e ' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . 'lint(cache = FALSE, commandArgs(TRUE), ' @@ -28,7 +28,7 @@ Execute(If the lint_package flag is set, lintr::lint_package should be called): let b:ale_r_lintr_lint_package = 1 AssertLinter 'Rscript', - \ 'cd ' . ale#Escape(getcwd()) . ' && ' + \ ale#path#CdString(getcwd()) \ . 'Rscript --vanilla -e ' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . 'lint_package(cache = FALSE, ' 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_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader index 988dfb1b..8ca35207 100644 --- a/test/command_callback/test_mypy_command_callback.vader +++ b/test/command_callback/test_mypy_command_callback.vader @@ -12,7 +12,7 @@ After: Execute(The mypy callbacks should return the correct default values): AssertLinter 'mypy', - \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy') + \ ale#path#CdString(g:dir) . ale#Escape('mypy') \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s' @@ -20,7 +20,7 @@ Execute(The mypy executable should be configurable, and escaped properly): let g:ale_python_mypy_executable = 'executable with spaces' AssertLinter 'executable with spaces', - \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('executable with spaces') + \ ale#path#CdString(g:dir) . ale#Escape('executable with spaces') \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s' @@ -28,7 +28,7 @@ Execute(The mypy command callback should let you set options): let g:ale_python_mypy_options = '--some-option' AssertLinter 'mypy', - \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy') + \ ale#path#CdString(g:dir) . ale#Escape('mypy') \ . ' --show-column-numbers --some-option ' \ . '--shadow-file %s %t %s' @@ -36,8 +36,8 @@ Execute(The mypy command should switch directories to the detected project root) silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py') AssertLinter 'mypy', - \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')) - \ . ' && ' . ale#Escape('mypy') + \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')) + \ . ale#Escape('mypy') \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s' @@ -47,8 +47,8 @@ Execute(The mypy callbacks should detect virtualenv directories and switch to th let b:executable = ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/mypy') AssertLinter b:executable, - \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')) - \ . ' && ' . ale#Escape(b:executable) + \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')) + \ . ale#Escape(b:executable) \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s' @@ -57,8 +57,8 @@ Execute(You should able able to use the global mypy instead): let g:ale_python_mypy_use_global = 1 AssertLinter 'mypy', - \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')) - \ . ' && ' . ale#Escape('mypy') + \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')) + \ . ale#Escape('mypy') \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s' @@ -69,3 +69,11 @@ Execute(Setting executable to 'pipenv' appends 'run mypy'): \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('path/to/pipenv') . ' run mypy' \ . ' --show-column-numbers --shadow-file %s %t %s' + +Execute(Pipenv is detected when python_mypy_auto_pipenv is set): + let g:ale_python_mypy_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s' diff --git a/test/command_callback/test_nasm_nasm_command_callbacks.vader b/test/command_callback/test_nasm_nasm_command_callbacks.vader index 4e0cf608..8e077306 100644 --- a/test/command_callback/test_nasm_nasm_command_callbacks.vader +++ b/test/command_callback/test_nasm_nasm_command_callbacks.vader @@ -2,9 +2,9 @@ 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 -o ' . (has('win32') ? 'NUL' : '/dev/null') let b:command_tail_opt = - \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s' + \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s -o ' . (has('win32') ? 'NUL' : '/dev/null') After: unlet! b:command_tail @@ -23,7 +23,7 @@ Execute(The options should be configurable): let b:ale_nasm_nasm_options = '-w-macro-params' AssertLinter 'nasm', ale#Escape('nasm') - \ . ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w-macro-params %s' + \ . ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w-macro-params %s -o ' . (has('win32') ? 'NUL' : '/dev/null') Execute(The options should be used in command): let b:ale_nasm_nasm_options = '-w+orphan-labels' diff --git a/test/command_callback/test_objc_ccls_command_callbacks.vader b/test/command_callback/test_objc_ccls_command_callbacks.vader new file mode 100644 index 00000000..9d0c7690 --- /dev/null +++ b/test/command_callback/test_objc_ccls_command_callbacks.vader @@ -0,0 +1,40 @@ +Before: + call ale#assert#SetUpLinterTest('objc', 'ccls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.m') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .ccls file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.m') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls') + +Execute(The project root should be detected correctly using .ccls-root file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls-root/dummy.m') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls-root') + +Execute(The executable should be configurable): + AssertLinter 'ccls', ale#Escape('ccls') + + let b:ale_objc_ccls_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(The initialization options should be configurable): + AssertLSPOptions {} + + let b:ale_objc_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } + + AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } diff --git a/test/command_callback/test_perl6_command_callback.vader b/test/command_callback/test_perl6_command_callback.vader new file mode 100644 index 00000000..d3ec6e17 --- /dev/null +++ b/test/command_callback/test_perl6_command_callback.vader @@ -0,0 +1,14 @@ +Before: + call ale#assert#SetUpLinterTest('perl6', 'perl6') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default Perl6 command callback should be correct): + AssertLinter 'perl6', 'perl6' . ' -c -Ilib %t' + +Execute(Overriding the executable and command should work): + let b:ale_perl6_perl6_executable = 'foobar' + let b:ale_perl6_perl6_options = '-w' + + AssertLinter 'foobar', 'foobar' . ' -w %t' diff --git a/test/command_callback/test_php_command_callback.vader b/test/command_callback/test_php_command_callback.vader new file mode 100644 index 00000000..670d7196 --- /dev/null +++ b/test/command_callback/test_php_command_callback.vader @@ -0,0 +1,15 @@ +Before: + call ale#assert#SetUpLinterTest('php', 'php') + let b:command_tail = ' -l -d error_reporting=E_ALL -d display_errors=1' + \ . ' -d log_errors=0 --' + +After: + unlet! b:command_tail + call ale#assert#TearDownLinterTest() + +Execute(The executable should be configurable): + AssertLinter 'php', ale#Escape('php') . b:command_tail + + let b:ale_php_php_executable = '/path/to/php' + + AssertLinter '/path/to/php', ale#Escape('/path/to/php') . b:command_tail 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..e5d2f449 --- /dev/null +++ b/test/command_callback/test_phpcs_command_callback.vader @@ -0,0 +1,35 @@ +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' + +Execute(User provided options are used): + let g:ale_php_phpcs_options = '--my-user-provided-option my-value' + + AssertLinter 'phpcs', + \ ale#Escape('phpcs') . ' -s --report=emacs --stdin-path=%s --my-user-provided-option my-value' diff --git a/test/command_callback/test_phpstan_command_callbacks.vader b/test/command_callback/test_phpstan_command_callbacks.vader index c7db587a..665661a3 100644 --- a/test/command_callback/test_phpstan_command_callbacks.vader +++ b/test/command_callback/test_phpstan_command_callbacks.vader @@ -1,6 +1,8 @@ Before: call ale#assert#SetUpLinterTest('php', 'phpstan') + WithChainResults ['0.10.2'] + After: call ale#assert#TearDownLinterTest() @@ -22,3 +24,11 @@ Execute(Custom phpstan configuration file): AssertLinter 'phpstan', \ ale#Escape('phpstan') . ' analyze -l4 --errorFormat raw -c phpstan_config %s' + +Execute(Choose the right format for error format param): + WithChainResults ['0.10.3'] + + AssertLinter 'phpstan', [ + \ ale#Escape('phpstan') . ' --version', + \ ale#Escape('phpstan') . ' analyze -l4 --error-format raw %s' + \ ] diff --git a/test/command_callback/test_prospector_command_callback.vader b/test/command_callback/test_prospector_command_callback.vader index 316b9883..0d692bde 100644 --- a/test/command_callback/test_prospector_command_callback.vader +++ b/test/command_callback/test_prospector_command_callback.vader @@ -10,3 +10,11 @@ Execute(Setting executable to 'pipenv' appends 'run prospector'): AssertLinter 'path/to/pipenv', \ ale#Escape('path/to/pipenv') . ' run prospector' \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s' + +Execute(Pipenv is detected when python_prospector_auto_pipenv is set): + let g:ale_python_prospector_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#Escape('pipenv') . ' run prospector' + \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s' diff --git a/test/command_callback/test_psalm_command_callbacks.vader b/test/command_callback/test_psalm_command_callbacks.vader new file mode 100644 index 00000000..d731054f --- /dev/null +++ b/test/command_callback/test_psalm_command_callbacks.vader @@ -0,0 +1,29 @@ +Before: + call ale#assert#SetUpLinterTest('php', 'psalm') + +After: + if isdirectory(g:dir . '/.git') + call delete(g:dir . '/.git', 'd') + endif + + call ale#assert#TearDownLinterTest() + +Execute(The default executable path should be correct): + AssertLinter 'psalm-language-server', + \ ale#Escape('psalm-language-server') + +Execute(Vendor executables should be detected): + call ale#test#SetFilename('psalm-project/test.php') + + AssertLinter + \ ale#path#Simplify(g:dir . '/psalm-project/vendor/bin/psalm-language-server'), + \ ale#Escape(ale#path#Simplify( + \ g:dir + \ . '/psalm-project/vendor/bin/psalm-language-server' + \ )) + +Execute(The project path should be correct for .git directories): + call ale#test#SetFilename('psalm-project/test.php') + call mkdir(g:dir . '/.git') + + AssertLSPProject g:dir
\ No newline at end of file diff --git a/test/command_callback/test_pycodestyle_command_callback.vader b/test/command_callback/test_pycodestyle_command_callback.vader index 851eede9..a3a338a9 100644 --- a/test/command_callback/test_pycodestyle_command_callback.vader +++ b/test/command_callback/test_pycodestyle_command_callback.vader @@ -24,3 +24,10 @@ Execute(Setting executable to 'pipenv' appends 'run pycodestyle'): AssertLinter 'path/to/pipenv', \ ale#Escape('path/to/pipenv') . ' run pycodestyle -' + +Execute(Pipenv is detected when python_pycodestyle_auto_pipenv is set): + let g:ale_python_pycodestyle_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#Escape('pipenv') . ' run pycodestyle -' diff --git a/test/command_callback/test_pyflakes_command_callback.vader b/test/command_callback/test_pyflakes_command_callback.vader index efc925fe..92f83820 100644 --- a/test/command_callback/test_pyflakes_command_callback.vader +++ b/test/command_callback/test_pyflakes_command_callback.vader @@ -37,3 +37,10 @@ Execute(Setting executable to 'pipenv' appends 'run pyflakes'): AssertLinter 'path/to/pipenv', \ ale#Escape('path/to/pipenv') . ' run pyflakes %t', + +Execute(Pipenv is detected when python_pyflakes_auto_pipenv is set): + let g:ale_python_pyflakes_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#Escape('pipenv') . ' run pyflakes %t' diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader index be2908f9..6b21b127 100644 --- a/test/command_callback/test_pylint_command_callback.vader +++ b/test/command_callback/test_pylint_command_callback.vader @@ -68,3 +68,12 @@ Execute(Setting executable to 'pipenv' appends 'run pylint'): \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('path/to/pipenv') . ' run pylint' \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' + +Execute(Pipenv is detected when python_pylint_auto_pipenv is set): + let g:ale_python_pylint_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('pipenv') . ' run pylint' + \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' diff --git a/test/command_callback/test_pyls_command_callback.vader b/test/command_callback/test_pyls_command_callback.vader index 53bf3000..531b5b3b 100644 --- a/test/command_callback/test_pyls_command_callback.vader +++ b/test/command_callback/test_pyls_command_callback.vader @@ -38,3 +38,10 @@ Execute(Setting executable to 'pipenv' appends 'run pyls'): let g:ale_python_pyls_executable = 'path/to/pipenv' AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run pyls' + +Execute(Pipenv is detected when python_pyls_auto_pipenv is set): + let g:ale_python_pyls_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#Escape('pipenv') . ' run pyls' diff --git a/test/command_callback/test_pyre_command_callback.vader b/test/command_callback/test_pyre_command_callback.vader index 6ad19b56..ba57c117 100644 --- a/test/command_callback/test_pyre_command_callback.vader +++ b/test/command_callback/test_pyre_command_callback.vader @@ -37,3 +37,10 @@ Execute(Setting executable to 'pipenv' appends 'run pyre'): AssertLinter 'path/to/pipenv', \ ale#Escape('path/to/pipenv') . ' run pyre persistent' + +Execute(Pipenv is detected when python_pyre_auto_pipenv is set): + let g:ale_python_pyre_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#Escape('pipenv') . ' run pyre persistent' diff --git a/test/command_callback/test_reek_command_callback.vader b/test/command_callback/test_reek_command_callback.vader index 059e5e36..a7cb7fb9 100644 --- a/test/command_callback/test_reek_command_callback.vader +++ b/test/command_callback/test_reek_command_callback.vader @@ -7,8 +7,8 @@ After: Execute(The reek callbacks should return the correct default values): WithChainResults ['reek 5.0.0'] AssertLinter 'reek', [ - \ 'reek --version', - \ 'reek -f json --no-progress --no-color --stdin-filename %s', + \ ale#Escape('reek') . ' --version', + \ ale#Escape('reek') . ' -f json --no-progress --no-color --force-exclusion --stdin-filename %s', \] " Try with older versions. @@ -16,19 +16,35 @@ Execute(The reek callbacks should return the correct default values): WithChainResults ['reek 4.8.2'] AssertLinter 'reek', [ - \ 'reek --version', - \ 'reek -f json --no-progress --no-color', + \ ale#Escape('reek') . ' --version', + \ ale#Escape('reek') . ' -f json --no-progress --no-color --force-exclusion', \] +Execute(Setting bundle appends 'exec reek'): + let g:ale_ruby_reek_executable = 'bundle' + + WithChainResults ['reek 5.0.0'] + AssertLinter 'bundle', ale#Escape('bundle') + \ . ' exec reek' + \ . ' -f json --no-progress --no-color --force-exclusion --stdin-filename %s', + + " Try with older versions. + call ale#semver#ResetVersionCache() + + WithChainResults ['reek 4.8.2'] + AssertLinter 'bundle', ale#Escape('bundle') + \ . ' exec reek' + \ . ' -f json --no-progress --no-color --force-exclusion' + Execute(The reek version check should be cached): WithChainResults ['reek 5.0.0'] AssertLinter 'reek', [ - \ 'reek --version', - \ 'reek -f json --no-progress --no-color --stdin-filename %s', + \ ale#Escape('reek') . ' --version', + \ ale#Escape('reek') . ' -f json --no-progress --no-color --force-exclusion --stdin-filename %s', \] WithChainResults [] AssertLinter 'reek', [ \ '', - \ 'reek -f json --no-progress --no-color --stdin-filename %s', + \ ale#Escape('reek') . ' -f json --no-progress --no-color --force-exclusion --stdin-filename %s', \] diff --git a/test/command_callback/test_ruby_solargraph.vader b/test/command_callback/test_ruby_solargraph.vader new file mode 100644 index 00000000..c6aee271 --- /dev/null +++ b/test/command_callback/test_ruby_solargraph.vader @@ -0,0 +1,44 @@ +" Author: Horacio Sanson <https://github.com/hsanson> +" Description: Tests for solargraph lsp linter. + +Before: + call ale#assert#SetUpLinterTest('ruby', 'solargraph') + +After: + call ale#assert#TearDownLinterTest() + +Execute(command callback should return default string): + AssertLinter 'solargraph', ale#Escape('solargraph') . ' stdio' + +Execute(command callback executable can be overridden): + let g:ale_ruby_solargraph_executable = 'foobar' + AssertLinter 'foobar', ale#Escape('foobar') . ' stdio' + +Execute(should set solargraph for rails app): + call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/models/thing.rb') + AssertLSPLanguage 'ruby' + AssertLSPOptions {} + AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_rails_app') + +Execute(should set solargraph for ruby app1): + call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app1/lib/file.rb') + AssertLSPLanguage 'ruby' + AssertLSPOptions {} + AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app1') + +Execute(should set solargraph for ruby app2): + call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app2/lib/file.rb') + AssertLSPLanguage 'ruby' + AssertLSPOptions {} + AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app2') + +Execute(should set solargraph for ruby app3): + call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app3/lib/file.rb') + AssertLSPLanguage 'ruby' + AssertLSPOptions {} + AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app3') + +Execute(should accept initialization options): + AssertLSPOptions {} + let b:ale_ruby_solargraph_options = { 'diagnostics': 'true' } + AssertLSPOptions { 'diagnostics': 'true' } diff --git a/test/command_callback/test_rustc_command_callback.vader b/test/command_callback/test_rustc_command_callback.vader index 7ca02760..f765e725 100644 --- a/test/command_callback/test_rustc_command_callback.vader +++ b/test/command_callback/test_rustc_command_callback.vader @@ -5,7 +5,7 @@ After: call ale#assert#TearDownLinterTest() Execute(The default command should be correct): - AssertLinter 'rustc', 'rustc --error-format=json -Z no-trans -' + AssertLinter 'rustc', 'rustc --error-format=json -Z no-codegen -' Execute(The options should be configurable): let b:ale_rust_rustc_options = '--foo' @@ -15,7 +15,7 @@ Execute(The options should be configurable): Execute(Some default paths should be included when the project is a Cargo project): call ale#test#SetFilename('cargo_paths/test.rs') - AssertLinter 'rustc', 'rustc --error-format=json -Z no-trans' + AssertLinter 'rustc', 'rustc --error-format=json -Z no-codegen' \ . ' -L ' . ale#Escape(ale#path#GetAbsPath(g:dir, 'cargo_paths/target/debug/deps')) \ . ' -L ' . ale#Escape(ale#path#GetAbsPath(g:dir, 'cargo_paths/target/release/deps')) \ . ' -' diff --git a/test/command_callback/test_ruumba_command_callback.vader b/test/command_callback/test_ruumba_command_callback.vader new file mode 100644 index 00000000..244b264a --- /dev/null +++ b/test/command_callback/test_ruumba_command_callback.vader @@ -0,0 +1,29 @@ +Before: + call ale#assert#SetUpLinterTest('eruby', 'ruumba') + call ale#test#SetFilename('dummy.html.erb') + + let g:ale_eruby_ruumba_executable = 'ruumba' + let g:ale_eruby_ruumba_options = '' + +After: + call ale#assert#TearDownLinterTest() + +Execute(Executable should default to ruumba): + AssertLinter 'ruumba', ale#Escape('ruumba') + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.html.erb')) + +Execute(Should be able to set a custom executable): + let g:ale_eruby_ruumba_executable = 'bin/ruumba' + + AssertLinter 'bin/ruumba' , ale#Escape('bin/ruumba') + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.html.erb')) + +Execute(Setting bundle appends 'exec ruumba'): + let g:ale_eruby_ruumba_executable = 'path to/bundle' + + AssertLinter 'path to/bundle', ale#Escape('path to/bundle') + \ . ' exec ruumba' + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.html.erb')) diff --git a/test/command_callback/test_sasslint_command_callback.vader b/test/command_callback/test_sasslint_command_callback.vader index 4d7cc4c7..9142c441 100644 --- a/test/command_callback/test_sasslint_command_callback.vader +++ b/test/command_callback/test_sasslint_command_callback.vader @@ -7,5 +7,5 @@ After: Execute(The default sasslint command should be correct): AssertLinter 'sass-lint', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('sass-lint') . ' -v -q -f compact %t' diff --git a/test/command_callback/test_scala_sbtserver.vader b/test/command_callback/test_scala_sbtserver.vader new file mode 100644 index 00000000..1c7d8472 --- /dev/null +++ b/test/command_callback/test_scala_sbtserver.vader @@ -0,0 +1,21 @@ +" Author: ophirr33 <coghlan.ty@gmail.com> +" Description: Tests for the sbt Server lsp linter + +Before: + call ale#assert#SetUpLinterTest('scala', 'sbtserver') +After: + call ale#assert#TearDownLinterTest() +Execute(should set sbtserver for sbt project with build.sbt): + call ale#test#SetFilename('../scala_fixtures/valid_sbt_project/Main.scala') + AssertLSPLanguage 'scala' + AssertLSPOptions {} + AssertLSPConfig {} + AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../scala_fixtures/valid_sbt_project') + AssertLSPAddress '127.0.0.1:4273' +Execute(should not set sbtserver for sbt project without build.sbt): + call ale#test#SetFilename('../scala_fixtures/invalid_sbt_project/Main.scala') + AssertLSPLanguage 'scala' + AssertLSPOptions {} + AssertLSPConfig {} + AssertLSPProject '' + AssertLSPAddress '127.0.0.1:4273' diff --git a/test/command_callback/test_scalac_command_callback.vader b/test/command_callback/test_scalac_command_callback.vader index 115731b3..5184aa0b 100644 --- a/test/command_callback/test_scalac_command_callback.vader +++ b/test/command_callback/test_scalac_command_callback.vader @@ -6,8 +6,8 @@ After: Given scala(An empty Scala file): Execute(The default executable and command should be correct): - AssertLinter 'scalac', ale#Escape('scalac') . ' -Ystop-after:parser %t' + AssertLinter 'scalac', ale#Escape('scalac') . ' -Ystop-before:jvm %t' 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_scss_stylelint_command_callback.vader b/test/command_callback/test_scss_stylelint_command_callback.vader new file mode 100644 index 00000000..9c3a02d8 --- /dev/null +++ b/test/command_callback/test_scss_stylelint_command_callback.vader @@ -0,0 +1,31 @@ +Before: + call ale#assert#SetUpLinterTest('scss', 'stylelint') + unlet! b:executable + +After: + unlet! b:executable + call ale#assert#TearDownLinterTest() + +Execute(node_modules directories should be discovered): + call ale#test#SetFilename('stylelint_paths/nested/testfile.scss') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/stylelint_paths/node_modules/.bin/stylelint' + \) + + AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin-filename %s' + +Execute(The global override should work): + let b:ale_scss_stylelint_executable = 'foobar' + let b:ale_scss_stylelint_use_global = 1 + + call ale#test#SetFilename('stylelint_paths/nested/testfile.scss') + + AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin-filename %s' + +Execute(Extra options should be configurable): + let b:ale_scss_stylelint_options = '--configFile ''/absolute/path/to/file''' + + AssertLinter 'stylelint', + \ ale#Escape('stylelint') . ' --configFile ''/absolute/path/to/file'' --stdin-filename %s' diff --git a/test/command_callback/test_shellcheck_command_callback.vader b/test/command_callback/test_shellcheck_command_callback.vader index 23684026..22a9ccb5 100644 --- a/test/command_callback/test_shellcheck_command_callback.vader +++ b/test/command_callback/test_shellcheck_command_callback.vader @@ -2,7 +2,7 @@ Before: call ale#assert#SetUpLinterTest('sh', 'shellcheck') call ale#test#SetFilename('test.sh') - let b:prefix = 'cd ' . ale#Escape(ale#path#Simplify(g:dir)) . ' && ' + let b:prefix = ale#path#CdString(ale#path#Simplify(g:dir)) let b:suffix = ' -f gcc -' After: diff --git a/test/command_callback/test_staticcheck_command_callback.vader b/test/command_callback/test_staticcheck_command_callback.vader index 918c12a0..7f17b146 100644 --- a/test/command_callback/test_staticcheck_command_callback.vader +++ b/test/command_callback/test_staticcheck_command_callback.vader @@ -7,7 +7,7 @@ After: Execute(The staticcheck callback should return the right defaults): AssertLinter 'staticcheck', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . 'staticcheck ' \ . ale#Escape(expand('%' . ':t')) @@ -15,7 +15,7 @@ Execute(The staticcheck callback should use configured options): let b:ale_go_staticcheck_options = '-test' AssertLinter 'staticcheck', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . 'staticcheck ' \ . '-test ' . ale#Escape(expand('%' . ':t')) @@ -23,4 +23,4 @@ Execute(The staticcheck `lint_package` option should use the correct command): let b:ale_go_staticcheck_lint_package = 1 AssertLinter 'staticcheck', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && staticcheck .', + \ ale#path#CdString(expand('%:p:h')) . 'staticcheck .', 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_thrift_command_callback.vader b/test/command_callback/test_thrift_command_callback.vader index ea217259..cbada818 100644 --- a/test/command_callback/test_thrift_command_callback.vader +++ b/test/command_callback/test_thrift_command_callback.vader @@ -23,22 +23,22 @@ After: call ale#assert#TearDownLinterTest() Execute(The default command should be correct): - AssertLinter 'thrift', ale#Escape('thrift') . ' --gen cpp -strict' . b:suffix + AssertLinter 'thrift', ale#Escape('thrift') . ' --gen cpp -I . -strict' . b:suffix Execute(The executable should be configurable): let b:ale_thrift_thrift_executable = 'foobar' - AssertLinter 'foobar', ale#Escape('foobar') . ' --gen cpp -strict' . b:suffix + AssertLinter 'foobar', ale#Escape('foobar') . ' --gen cpp -I . -strict' . b:suffix Execute(The list of generators should be configurable): let b:ale_thrift_thrift_generators = ['java', 'py:dynamic'] AssertLinter 'thrift', ale#Escape('thrift') - \ . ' --gen java --gen py:dynamic -strict' . b:suffix + \ . ' --gen java --gen py:dynamic -I . -strict' . b:suffix let b:ale_thrift_thrift_generators = [] - AssertLinter 'thrift', ale#Escape('thrift') . ' --gen cpp -strict' . b:suffix + AssertLinter 'thrift', ale#Escape('thrift') . ' --gen cpp -I . -strict' . b:suffix Execute(The list of include paths should be configurable): let b:ale_thrift_thrift_includes = ['included/path'] @@ -50,4 +50,4 @@ Execute(The string of compiler options should be configurable): let b:ale_thrift_thrift_options = '-strict --allow-64bit-consts' AssertLinter 'thrift', ale#Escape('thrift') - \ . ' --gen cpp -strict --allow-64bit-consts' . b:suffix + \ . ' --gen cpp -I . -strict --allow-64bit-consts' . b:suffix diff --git a/test/command_callback/test_tslint_command_callback.vader b/test/command_callback/test_tslint_command_callback.vader index bd8a12ec..229ccc96 100644 --- a/test/command_callback/test_tslint_command_callback.vader +++ b/test/command_callback/test_tslint_command_callback.vader @@ -7,14 +7,14 @@ After: Execute(The default tslint command should be correct): AssertLinter 'tslint', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('tslint') . ' --format json %t' Execute(The rules directory option should be included if set): let b:ale_typescript_tslint_rules_dir = '/foo/bar' AssertLinter 'tslint', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('tslint') . ' --format json' \ . ' -r ' . ale#Escape('/foo/bar') \ . ' %t' @@ -23,5 +23,5 @@ Execute(The executable should be configurable and escaped): let b:ale_typescript_tslint_executable = 'foo bar' AssertLinter 'foo bar', - \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ ale#path#CdString(expand('%:p:h')) \ . ale#Escape('foo bar') . ' --format 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') |