diff options
author | Bartek thindil Jasicki <thindil@laeran.pl> | 2020-08-07 17:43:11 +0200 |
---|---|---|
committer | Bartek thindil Jasicki <thindil@laeran.pl> | 2020-08-07 17:43:11 +0200 |
commit | 973c4ea053f78d4daa6eceff36da0bbecd788077 (patch) | |
tree | f63fcce4cebada3930737a3068ec9baa3571a1b9 /test/command_callback | |
parent | 9a9d12cf4f3dda8ab45d38b10d5f3e01efc9b5d6 (diff) | |
parent | f741245f11007819e81632e13690ebcf9b6c3f40 (diff) | |
download | ale-973c4ea053f78d4daa6eceff36da0bbecd788077.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test/command_callback')
13 files changed, 192 insertions, 6 deletions
diff --git a/test/command_callback/ccls_paths/with_build_dir/unusual_build_dir_name/compile_commands.json b/test/command_callback/ccls_paths/with_build_dir/unusual_build_dir_name/compile_commands.json new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/ccls_paths/with_build_dir/unusual_build_dir_name/compile_commands.json diff --git a/test/command_callback/hdl_server/foo.vhd b/test/command_callback/hdl_server/foo.vhd new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/hdl_server/foo.vhd diff --git a/test/command_callback/hdl_server/with_config_file/.hdl_checker.config b/test/command_callback/hdl_server/with_config_file/.hdl_checker.config new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/hdl_server/with_config_file/.hdl_checker.config diff --git a/test/command_callback/hdl_server/with_config_file/_hdl_checker.config b/test/command_callback/hdl_server/with_config_file/_hdl_checker.config new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/hdl_server/with_config_file/_hdl_checker.config diff --git a/test/command_callback/hdl_server/with_config_file/foo.vhd b/test/command_callback/hdl_server/with_config_file/foo.vhd new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/hdl_server/with_config_file/foo.vhd diff --git a/test/command_callback/hdl_server/with_git/files/foo.vhd b/test/command_callback/hdl_server/with_git/files/foo.vhd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/command_callback/hdl_server/with_git/files/foo.vhd @@ -0,0 +1 @@ + diff --git a/test/command_callback/test_c_ccls_command_callbacks.vader b/test/command_callback/test_c_ccls_command_callbacks.vader index 43fdb366..04643d02 100644 --- a/test/command_callback/test_c_ccls_command_callbacks.vader +++ b/test/command_callback/test_c_ccls_command_callbacks.vader @@ -4,6 +4,10 @@ Before: call ale#assert#SetUpLinterTest('c', 'ccls') + Save b:ale_c_build_dir_names + Save b:ale_c_ccls_executable + Save b:ale_c_ccls_init_options + After: call ale#assert#TearDownLinterTest() @@ -47,3 +51,19 @@ Execute(The initialization options should be configurable): let b:ale_c_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } + +Execute(The compile command database should be detected correctly): + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.c') + + AssertLSPOptions {} + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.c') + + AssertLSPOptions { 'compilationDatabaseDirectory': + \ ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') } + + call ale#test#SetFilename('ccls_paths/with_build_dir/dummy.c') + let b:ale_c_build_dir_names = ['unusual_build_dir_name'] + + AssertLSPOptions { 'compilationDatabaseDirectory': + \ ale#path#Simplify(g:dir . '/ccls_paths/with_build_dir/unusual_build_dir_name') } diff --git a/test/command_callback/test_c_cppcheck_command_callbacks.vader b/test/command_callback/test_c_cppcheck_command_callbacks.vader index 3d487a31..b6ea3179 100644 --- a/test/command_callback/test_c_cppcheck_command_callbacks.vader +++ b/test/command_callback/test_c_cppcheck_command_callbacks.vader @@ -1,7 +1,6 @@ Before: call ale#assert#SetUpLinterTest('c', 'cppcheck') - - let b:command_tail = ' -q --language=c --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t' + let b:command_tail = ' -q --language=c --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'' --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t' After: " Remove a test file we might open for some tests. @@ -10,9 +9,8 @@ After: set buftype=nofile endif - call ale#assert#TearDownLinterTest() - unlet! b:command_tail + call ale#assert#TearDownLinterTest() Execute(The executable should be configurable): AssertLinter 'cppcheck', ale#Escape('cppcheck') . b:command_tail @@ -28,6 +26,7 @@ Execute(cppcheck for C should detect compile_commands.json files): \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ale#Escape('cppcheck') \ . ' -q --language=c' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --project=' . ale#Escape('compile_commands.json') \ . ' --enable=style %t' @@ -38,6 +37,7 @@ Execute(cppcheck for C should detect compile_commands.json files in build direct \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir')) \ . ale#Escape('cppcheck') \ . ' -q --language=c' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --project=' . ale#Escape(ale#path#Simplify('build/compile_commands.json')) \ . ' --enable=style %t' @@ -47,6 +47,7 @@ Execute(cppcheck for C should include file dir if compile_commands.json file is AssertLinter 'cppcheck', \ ale#Escape('cppcheck') \ . ' -q --language=c' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --enable=style' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths')) \ . ' %t' @@ -61,6 +62,7 @@ Execute(cppcheck for C should ignore compile_commands.json file if buffer is mod \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ale#Escape('cppcheck') \ . ' -q --language=c' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --enable=style' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ' %t' diff --git a/test/command_callback/test_cpp_ccls_command_callbacks.vader b/test/command_callback/test_cpp_ccls_command_callbacks.vader index eece42bc..f603ac07 100644 --- a/test/command_callback/test_cpp_ccls_command_callbacks.vader +++ b/test/command_callback/test_cpp_ccls_command_callbacks.vader @@ -4,6 +4,10 @@ Before: call ale#assert#SetUpLinterTest('cpp', 'ccls') + Save b:ale_c_build_dir_names + Save b:ale_cpp_ccls_executable + Save b:ale_cpp_ccls_init_options + After: call ale#assert#TearDownLinterTest() @@ -47,3 +51,19 @@ Execute(The initialization options should be configurable): let b:ale_cpp_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } + +Execute(The compile command database should be detected correctly): + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.c') + + AssertLSPOptions {} + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.c') + + AssertLSPOptions { 'compilationDatabaseDirectory': + \ ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') } + + call ale#test#SetFilename('ccls_paths/with_build_dir/dummy.c') + let b:ale_c_build_dir_names = ['unusual_build_dir_name'] + + AssertLSPOptions { 'compilationDatabaseDirectory': + \ ale#path#Simplify(g:dir . '/ccls_paths/with_build_dir/unusual_build_dir_name') } diff --git a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader index 02bdf748..b19c09b1 100644 --- a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader +++ b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader @@ -1,6 +1,6 @@ Before: call ale#assert#SetUpLinterTest('cpp', 'cppcheck') - let b:command_tail = ' -q --language=c++ --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t' + let b:command_tail = ' -q --language=c++ --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'' --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t' After: " Remove a test file we might open for some tests. @@ -26,6 +26,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files): \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ale#Escape('cppcheck') \ . ' -q --language=c++' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --project=' . ale#Escape('compile_commands.json') \ . ' --enable=style %t' @@ -36,6 +37,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files in build dire \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir')) \ . ale#Escape('cppcheck') \ . ' -q --language=c++' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --project=' . ale#Escape(ale#path#Simplify('build/compile_commands.json')) \ . ' --enable=style %t' @@ -45,6 +47,7 @@ Execute(cppcheck for C++ should include file dir if compile_commands.json file i AssertLinter 'cppcheck', \ ale#Escape('cppcheck') \ . ' -q --language=c++' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --enable=style' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths')) \ . ' %t' @@ -59,6 +62,7 @@ Execute(cppcheck for C++ should ignore compile_commands.json file if buffer is m \ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ale#Escape('cppcheck') \ . ' -q --language=c++' + \ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' \ . ' --enable=style' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) \ . ' %t' diff --git a/test/command_callback/test_gopls_command_callback.vader b/test/command_callback/test_gopls_command_callback.vader index 92b20b18..73fcbf03 100644 --- a/test/command_callback/test_gopls_command_callback.vader +++ b/test/command_callback/test_gopls_command_callback.vader @@ -49,7 +49,10 @@ Execute(Should return directory for 'go.mod' if found in parent directory): Execute(Should return nearest directory with '.git' if found in parent directory): call ale#test#SetFilename('test.go') - call mkdir(g:dir . '/.git') + + if !isdirectory(g:dir . '/.git') + call mkdir(g:dir . '/.git') + endif AssertLSPProject g:dir diff --git a/test/command_callback/test_objc_ccls_command_callbacks.vader b/test/command_callback/test_objc_ccls_command_callbacks.vader index 5aa69d6a..34b8539e 100644 --- a/test/command_callback/test_objc_ccls_command_callbacks.vader +++ b/test/command_callback/test_objc_ccls_command_callbacks.vader @@ -1,6 +1,10 @@ Before: call ale#assert#SetUpLinterTest('objc', 'ccls') + Save b:ale_c_build_dir_names + Save b:ale_objc_ccls_executable + Save b:ale_objc_ccls_init_options + After: call ale#assert#TearDownLinterTest() @@ -44,3 +48,19 @@ Execute(The initialization options should be configurable): let b:ale_objc_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } + +Execute(The compile command database should be detected correctly): + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.c') + + AssertLSPOptions {} + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.c') + + AssertLSPOptions { 'compilationDatabaseDirectory': + \ ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') } + + call ale#test#SetFilename('ccls_paths/with_build_dir/dummy.c') + let b:ale_c_build_dir_names = ['unusual_build_dir_name'] + + AssertLSPOptions { 'compilationDatabaseDirectory': + \ ale#path#Simplify(g:dir . '/ccls_paths/with_build_dir/unusual_build_dir_name') } diff --git a/test/command_callback/test_pyright_command_callback.vader b/test/command_callback/test_pyright_command_callback.vader new file mode 100644 index 00000000..3e421bd9 --- /dev/null +++ b/test/command_callback/test_pyright_command_callback.vader @@ -0,0 +1,116 @@ +Before: + call ale#assert#SetUpLinterTest('python', 'pyright') + + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + +After: + unlet! b:bin_dir + unlet! b:executable + + call ale#assert#TearDownLinterTest() + +Execute(The command callback should return the correct default string): + AssertLinter + \ 'pyright-langserver', + \ ale#Escape('pyright-langserver') . ' --stdio' + +Execute(The executable should be configurable): + let g:ale_python_pyright_executable = '/bin/foo-bar' + + AssertLinter + \ '/bin/foo-bar', + \ ale#Escape('/bin/foo-bar') . ' --stdio' + +Execute(The default configuration should be mostly empty): + " The default configuration needs to have at least one key in it, + " or the server won't start up properly. + AssertLSPConfig {'python': {}} + + let b:ale_python_pyright_config = {} + + AssertLSPConfig {'python': {}} + +Execute(virtualenv paths should be set in configuration by default): + call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py') + + AssertLSPConfig { + \ 'python': { + \ 'pythonPath': ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/python'), + \ 'venvPath': ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env'), + \ }, + \} + +Execute(The pythonPath should be set based on whatever the ovveride for the venvPath is set to): + call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py') + + " This overrides the default detection of the path. + let b:ale_python_pyright_config = { + \ 'python': { + \ 'venvPath': '/foo/bar', + \ }, + \} + + AssertLSPConfig { + \ 'python': { + \ 'pythonPath': ale#path#Simplify('/foo/bar/' . b:bin_dir . '/python'), + \ 'venvPath': '/foo/bar', + \ }, + \} + +Execute(You should be able to override pythonPath when venvPath is detected): + call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py') + + " This overrides the default detection of the path. + let b:ale_python_pyright_config = { + \ 'python': { + \ 'pythonPath': '/bin/python', + \ }, + \} + + AssertLSPConfig { + \ 'python': { + \ 'pythonPath': '/bin/python', + \ 'venvPath': ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env'), + \ }, + \} + +Execute(You should be able to override both pythonPath and venvPath): + call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py') + + " This overrides the default detection of the path. + let b:ale_python_pyright_config = { + \ 'python': { + \ 'pythonPath': '/bin/python', + \ 'venvPath': '/other/dir', + \ }, + \} + + AssertLSPConfig { + \ 'python': { + \ 'pythonPath': '/bin/python', + \ 'venvPath': '/other/dir', + \ }, + \} + +Execute(You should be able to define other settings): + call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py') + + let b:ale_python_pyright_config = { + \ 'python': { + \ 'analysis': {'logLevel': 'warning'}, + \ }, + \ 'pyright': { + \ 'disableLanguageServices': v:true, + \ }, + \} + + AssertLSPConfig { + \ 'python': { + \ 'analysis': {'logLevel': 'warning'}, + \ 'pythonPath': ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/python'), + \ 'venvPath': ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env'), + \ }, + \ 'pyright': { + \ 'disableLanguageServices': v:true, + \ }, + \} |