From 626e47f5c9c3c86fef56020bedae996e8b026a9f Mon Sep 17 00:00:00 2001 From: Ye Jingchen Date: Wed, 26 Sep 2018 22:50:43 +0800 Subject: Add ccls tests --- ale_linters/c/ccls.vim | 4 +- ale_linters/cpp/ccls.vim | 4 +- ale_linters/objc/ccls.vim | 4 +- doc/ale.txt | 6 +-- .../compile_commands.json | 0 .../test_c_ccls_command_callbacks.vader | 43 ++++++++++++++++++++++ .../test_cpp_ccls_command_callbacks.vader | 43 ++++++++++++++++++++++ .../test_objc_ccls_command_callbacks.vader | 40 ++++++++++++++++++++ 8 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 test/command_callback/ccls_paths/with_compile_commands_json/compile_commands.json create mode 100644 test/command_callback/test_c_ccls_command_callbacks.vader create mode 100644 test/command_callback/test_cpp_ccls_command_callbacks.vader create mode 100644 test/command_callback/test_objc_ccls_command_callbacks.vader diff --git a/ale_linters/c/ccls.vim b/ale_linters/c/ccls.vim index 0aad0a3d..d0fa566e 100644 --- a/ale_linters/c/ccls.vim +++ b/ale_linters/c/ccls.vim @@ -9,7 +9,9 @@ function! ale_linters#c#ccls#GetProjectRoot(buffer) abort if empty(l:project_root) let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') - elseif empty(l:project_root) + endif + + if empty(l:project_root) let l:project_root = ale#path#FindNearestFile(a:buffer, '.ccls') endif diff --git a/ale_linters/cpp/ccls.vim b/ale_linters/cpp/ccls.vim index e63849c3..f1604f30 100644 --- a/ale_linters/cpp/ccls.vim +++ b/ale_linters/cpp/ccls.vim @@ -9,7 +9,9 @@ function! ale_linters#cpp#ccls#GetProjectRoot(buffer) abort if empty(l:project_root) let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') - elseif empty(l:project_root) + endif + + if empty(l:project_root) let l:project_root = ale#path#FindNearestFile(a:buffer, '.ccls') endif diff --git a/ale_linters/objc/ccls.vim b/ale_linters/objc/ccls.vim index f354c7d7..e6736df7 100644 --- a/ale_linters/objc/ccls.vim +++ b/ale_linters/objc/ccls.vim @@ -9,7 +9,9 @@ function! ale_linters#objc#ccls#GetProjectRoot(buffer) abort if empty(l:project_root) let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') - elseif empty(l:project_root) + endif + + if empty(l:project_root) let l:project_root = ale#path#FindNearestFile(a:buffer, '.ccls') endif diff --git a/doc/ale.txt b/doc/ale.txt index 00765e73..e8e3b477 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -378,8 +378,8 @@ Notes: * Awk: `gawk` * Bash: `language-server`, `shell` (-n flag), `shellcheck`, `shfmt` * Bourne Shell: `shell` (-n flag), `shellcheck`, `shfmt` -* C: `cppcheck`, `cpplint`!!, `clang`, `clangd`, `clangtidy`!!, `clang-format`, `cquery`, `flawfinder`, `gcc`, `uncrustify` -* C++ (filetype cpp): `clang`, `clangd`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `clazy`!!, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc`, `uncrustify` +* C: `cppcheck`, `cpplint`!!, `clang`, `clangd`, `clangtidy`!!, `clang-format`, `cquery`, `flawfinder`, `gcc`, `uncrustify`, `ccls` +* C++ (filetype cpp): `clang`, `clangd`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `clazy`!!, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc`, `uncrustify`, `ccls` * CUDA: `nvcc`!! * C#: `mcs`, `mcsc`!!, `uncrustify` * Chef: `foodcritic` @@ -431,7 +431,7 @@ Notes: * Nim: `nim check`!! * nix: `nix-instantiate` * nroff: `alex`!!, `proselint`, `write-good` -* Objective-C: `clang`, `clangd`, `uncrustify` +* Objective-C: `clang`, `clangd`, `uncrustify`, `ccls` * Objective-C++: `clang`, `clangd`, `uncrustify` * OCaml: `merlin` (see |ale-ocaml-merlin|), `ols`, `ocamlformat` * Pawn: `uncrustify` 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 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 , Ben Falconer +" 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_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 , Ben Falconer +" 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_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' } -- cgit v1.2.3