summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBartek thindil Jasicki <thindil@laeran.pl>2020-08-07 17:43:11 +0200
committerBartek thindil Jasicki <thindil@laeran.pl>2020-08-07 17:43:11 +0200
commit973c4ea053f78d4daa6eceff36da0bbecd788077 (patch)
treef63fcce4cebada3930737a3068ec9baa3571a1b9 /test
parent9a9d12cf4f3dda8ab45d38b10d5f3e01efc9b5d6 (diff)
parentf741245f11007819e81632e13690ebcf9b6c3f40 (diff)
downloadale-973c4ea053f78d4daa6eceff36da0bbecd788077.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/ccls_paths/with_build_dir/unusual_build_dir_name/compile_commands.json0
-rw-r--r--test/command_callback/hdl_server/foo.vhd0
-rw-r--r--test/command_callback/hdl_server/with_config_file/.hdl_checker.config0
-rw-r--r--test/command_callback/hdl_server/with_config_file/_hdl_checker.config0
-rw-r--r--test/command_callback/hdl_server/with_config_file/foo.vhd0
-rw-r--r--test/command_callback/hdl_server/with_git/files/foo.vhd1
-rw-r--r--test/command_callback/test_c_ccls_command_callbacks.vader20
-rw-r--r--test/command_callback/test_c_cppcheck_command_callbacks.vader10
-rw-r--r--test/command_callback/test_cpp_ccls_command_callbacks.vader20
-rw-r--r--test/command_callback/test_cpp_cppcheck_command_callbacks.vader6
-rw-r--r--test/command_callback/test_gopls_command_callback.vader5
-rw-r--r--test/command_callback/test_objc_ccls_command_callbacks.vader20
-rw-r--r--test/command_callback/test_pyright_command_callback.vader116
-rw-r--r--test/completion/test_lsp_completion_parsing.vader70
-rw-r--r--test/completion/test_public_completion_api.vader1
-rw-r--r--test/fixers/test_astyle_fixer_callback.vader30
-rw-r--r--test/handler/test_cppcheck_handler.vader26
-rw-r--r--test/handler/test_go_generic_handler.vader16
-rw-r--r--test/handler/test_markdownlint_handler.vader14
-rw-r--r--test/lsp/test_other_initialize_message_handling.vader53
-rw-r--r--test/test_autocmd_commands.vader28
-rw-r--r--test/test_cpp_project/.astylerc0
-rw-r--r--test/test_cpp_project/dummy.cpp0
-rw-r--r--test/test_filetype_linter_defaults.vader4
-rw-r--r--test/test_hdl_checker_options.vader78
-rw-r--r--test/test_hover.vader7
-rw-r--r--test/test_rename.vader109
27 files changed, 611 insertions, 23 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,
+ \ },
+ \}
diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader
index 1fdbbd96..e233c955 100644
--- a/test/completion/test_lsp_completion_parsing.vader
+++ b/test/completion/test_lsp_completion_parsing.vader
@@ -526,3 +526,73 @@ Execute(Should handle completion messages with the deprecated insertText attribu
\ ],
\ },
\ })
+
+Execute(Should handle completion messages with additionalTextEdits):
+ AssertEqual
+ \ [
+ \ {
+ \ 'word': 'next_callback',
+ \ 'menu': 'PlayTimeCallback',
+ \ 'info': '',
+ \ 'kind': 'v',
+ \ 'icase': 1,
+ \ 'user_data': json_encode({
+ \ 'codeActions': [
+ \ {
+ \ 'description': 'completion',
+ \ 'changes': [
+ \ {
+ \ 'fileName': expand('#' . bufnr('') . ':p'),
+ \ 'textChanges': [
+ \ {
+ \ 'start': {
+ \ 'line': 11,
+ \ 'offset': 2,
+ \ },
+ \ 'end': {
+ \ 'line': 13,
+ \ 'offset': 4,
+ \ },
+ \ 'newText': 'from "module" import next_callback',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ }),
+ \ },
+ \ ],
+ \ ale#completion#ParseLSPCompletions({
+ \ 'id': 226,
+ \ 'jsonrpc': '2.0',
+ \ 'result': {
+ \ 'isIncomplete': v:false,
+ \ 'items': [
+ \ {
+ \ 'detail': 'PlayTimeCallback',
+ \ 'filterText': 'next_callback',
+ \ 'insertText': 'next_callback',
+ \ 'insertTextFormat': 1,
+ \ 'kind': 6,
+ \ 'label': ' next_callback',
+ \ 'sortText': '3ee19999next_callback',
+ \ 'additionalTextEdits': [
+ \ {
+ \ 'range': {
+ \ 'start': {
+ \ 'line': 10,
+ \ 'character': 1,
+ \ },
+ \ 'end': {
+ \ 'line': 12,
+ \ 'character': 3,
+ \ },
+ \ },
+ \ 'newText': 'from "module" import next_callback',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \ })
diff --git a/test/completion/test_public_completion_api.vader b/test/completion/test_public_completion_api.vader
index c3cd42b8..f26fdc12 100644
--- a/test/completion/test_public_completion_api.vader
+++ b/test/completion/test_public_completion_api.vader
@@ -37,6 +37,7 @@ Execute(ale#completion#GetCompletionPositionForDeoplete() should return the posi
AssertEqual 4, ale#completion#GetCompletionPositionForDeoplete('foo bar')
Execute(ale#completion#CanProvideCompletions should return 0 when no completion sources are available):
+ let b:ale_linters = ['flake8']
AssertEqual 0, ale#completion#CanProvideCompletions()
Execute(ale#completion#CanProvideCompletions should return 1 when at least one completion source is available):
diff --git a/test/fixers/test_astyle_fixer_callback.vader b/test/fixers/test_astyle_fixer_callback.vader
index cbec4493..ac756870 100644
--- a/test/fixers/test_astyle_fixer_callback.vader
+++ b/test/fixers/test_astyle_fixer_callback.vader
@@ -20,11 +20,12 @@ Execute(The astyle callback should return the correct default values):
" Because this file doesn't exist, no astylrc config
" exists near it. Therefore, project_options is empty.
call ale#test#SetFilename('../c_files/testfile.c')
+ let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_astyle_executable)
- \ . ' --stdin='
+ \ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
@@ -33,46 +34,63 @@ Execute(The astyle callback should support cpp files):
" exists near it. Therefore, project_options is empty.
call ale#test#SetFilename('../cpp_files/dummy.cpp')
set filetype=cpp " The test fails without this
+ let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_cpp_astyle_executable)
- \ . ' --stdin='
+ \ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
Execute(The astyle callback should support cpp files with option file set):
call ale#test#SetFilename('../cpp_files/dummy.cpp')
let g:ale_cpp_astyle_project_options = '.astylerc_cpp'
+ let targetfile = bufname(bufnr('%'))
set filetype=cpp " The test fails without this
AssertEqual
\ {
\ 'command': ale#Escape('invalidpp')
\ . ' --project=' . g:ale_cpp_astyle_project_options
- \ . ' --stdin='
+ \ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
-Execute(The astyle callback should return the correct default values with an option file set):
+Execute(The astyle callback should return the correct default values with a specified option file):
call ale#test#SetFilename('../c_files/testfile.c')
let g:ale_c_astyle_project_options = '.astylerc_c'
+ let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --project=' . g:ale_c_astyle_project_options
- \ . ' --stdin='
+ \ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
Execute(The astyle callback should find nearest default option file _astylrc):
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c')
+ let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --project=_astylerc'
- \ . ' --stdin='
+ \ . ' --stdin=' . ale#Escape(targetfile)
+ \ },
+ \ ale#fixers#astyle#Fix(bufnr(''))
+
+Execute(The astyle callback should find .astylrc in the same directory as src):
+ call ale#test#SetFilename('../test_cpp_project/dummy.cpp')
+ set filetype=cpp " The test fails without this
+ let targetfile = bufname(bufnr('%'))
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('invalidpp')
+ \ . ' --project=.astylerc'
+ \ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
diff --git a/test/handler/test_cppcheck_handler.vader b/test/handler/test_cppcheck_handler.vader
index f153b9b5..55a5d29b 100644
--- a/test/handler/test_cppcheck_handler.vader
+++ b/test/handler/test_cppcheck_handler.vader
@@ -10,19 +10,29 @@ Execute(Basic errors should be handled by cppcheck):
AssertEqual
\ [
\ {
- \ 'lnum': 5,
+ \ 'lnum': 974,
+ \ 'col' : 6,
\ 'type': 'E',
- \ 'text': 'Array ''a[10]'' accessed at index 10, which is out of bounds',
+ \ 'sub_type': '',
+ \ 'text': 'Array ''n[3]'' accessed at index 3, which is out of bounds.',
+ \ 'code': 'arrayIndexOutOfBounds'
\ },
\ {
- \ 'lnum': 7,
+ \ 'lnum': 1185,
+ \ 'col' : 10,
\ 'type': 'W',
- \ 'text': 'Some other problem',
+ \ 'sub_type': 'style',
+ \ 'text': 'The scope of the variable ''indxStr'' can be reduced.',
+ \ 'code': 'variableScope'
\ },
\ ],
\ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [
- \ '[test.cpp:5]: (error) Array ''a[10]'' accessed at index 10, which is out of bounds',
- \ '[test.cpp:7]: (warning) Some other problem',
+ \ 'test.cpp:974:6: error: Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\',
+ \ ' n[3]=3;',
+ \ ' ^',
+ \ 'test.cpp:1185:10: style: The scope of the variable ''indxStr'' can be reduced. [variableScope]\',
+ \ ' char indxStr[16];',
+ \ ' ^',
\ ])
Execute(Problems from other files should be ignored by cppcheck):
@@ -32,5 +42,7 @@ Execute(Problems from other files should be ignored by cppcheck):
\ [
\ ],
\ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [
- \ '[bar.cpp:5]: (error) Array ''a[10]'' accessed at index 10, which is out of bounds',
+ \ 'bar.cpp:974:6: error: Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\',
+ \ ' n[3]=3;',
+ \ ' ^',
\ ])
diff --git a/test/handler/test_go_generic_handler.vader b/test/handler/test_go_generic_handler.vader
index 624e56c1..2b17fdcb 100644
--- a/test/handler/test_go_generic_handler.vader
+++ b/test/handler/test_go_generic_handler.vader
@@ -15,8 +15,24 @@ Execute(The golang handler should return the correct filenames):
\ 'type': 'E',
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/other.go'),
\ },
+ \ {
+ \ 'lnum': 18,
+ \ 'col': 0,
+ \ 'text': 'random error',
+ \ 'type': 'E',
+ \ 'filename': ale#path#Simplify(expand('%:p:h') . '/go1.14.go'),
+ \ },
+ \ {
+ \ 'lnum': 36,
+ \ 'col': 2,
+ \ 'text': 'another random error',
+ \ 'type': 'E',
+ \ 'filename': ale#path#Simplify(expand('%:p:h') . '/anothergo1.14.go'),
+ \ },
\ ],
\ ale#handlers#go#Handler(bufnr(''), [
\ 'test.go:27: some error',
\ 'other.go:27:5: some error with a column',
+ \ 'vet: go1.14.go:18:0: random error',
+ \ 'vet: anothergo1.14.go:36:2: another random error',
\ ])
diff --git a/test/handler/test_markdownlint_handler.vader b/test/handler/test_markdownlint_handler.vader
index 8e9f77a0..f2e6e328 100644
--- a/test/handler/test_markdownlint_handler.vader
+++ b/test/handler/test_markdownlint_handler.vader
@@ -75,3 +75,17 @@ Execute(The Markdownlint handler should parse post v0.22.0 output with column co
\ ale#handlers#markdownlint#Handle(0, [
\ 'README.md:10:20 MD013/line-length Line length [Expected: 80; Actual: 114]'
\ ])
+
+Execute(The Markdownlint handler should parse output with multiple slashes in rule name correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 10,
+ \ 'code': 'MD022/blanks-around-headings/blanks-around-headers',
+ \ 'text': 'Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Above] [Context: "### something"]',
+ \ 'type': 'W'
+ \ }
+ \ ],
+ \ ale#handlers#markdownlint#Handle(0, [
+ \ 'README.md:10 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Above] [Context: "### something"]'
+ \ ])
diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader
index 6473e283..b6ef852a 100644
--- a/test/lsp/test_other_initialize_message_handling.vader
+++ b/test/lsp/test_other_initialize_message_handling.vader
@@ -131,7 +131,7 @@ Execute(Disabled capabilities should be recognised correctly):
\ },
\ 'definitionProvider': v:false,
\ 'experimental': {},
- \ 'documentHighlightProvider': v:true
+ \ 'documentHighlightProvider': v:true,
\ },
\ },
\})
@@ -150,6 +150,57 @@ Execute(Disabled capabilities should be recognised correctly):
\ b:conn.capabilities
AssertEqual [[1, 'initialized', {}]], g:message_list
+Execute(Capabilities should be enabled when send as Dictionaries):
+ call ale#lsp#HandleInitResponse(b:conn, {
+ \ 'jsonrpc': '2.0',
+ \ 'id': 1,
+ \ 'result': {
+ \ 'capabilities': {
+ \ 'renameProvider': {},
+ \ 'executeCommandProvider': {
+ \ 'commands': [],
+ \ },
+ \ 'hoverProvider': {},
+ \ 'documentSymbolProvider': v:true,
+ \ 'documentRangeFormattingProvider': v:true,
+ \ 'codeLensProvider': {
+ \ 'resolveProvider': v:false
+ \ },
+ \ 'completionProvider': {
+ \ 'triggerCharacters': ['.'],
+ \ 'resolveProvider': v:false
+ \ },
+ \ 'referencesProvider': {},
+ \ 'textDocumentSync': 2,
+ \ 'documentFormattingProvider': v:true,
+ \ 'codeActionProvider': v:true,
+ \ 'signatureHelpProvider': {
+ \ 'triggerCharacters': ['(', ','],
+ \ },
+ \ 'definitionProvider': {},
+ \ 'typeDefinitionProvider': {},
+ \ 'experimental': {},
+ \ 'documentHighlightProvider': v:true,
+ \ 'workspaceSymbolProvider': {}
+ \ },
+ \ },
+ \})
+
+ AssertEqual 1, b:conn.initialized
+ AssertEqual
+ \ {
+ \ 'completion_trigger_characters': ['.'],
+ \ 'completion': 1,
+ \ 'references': 1,
+ \ 'hover': 1,
+ \ 'definition': 1,
+ \ 'typeDefinition': 1,
+ \ 'symbol_search': 1,
+ \ 'rename': 1,
+ \ },
+ \ b:conn.capabilities
+ AssertEqual [[1, 'initialized', {}]], g:message_list
+
Execute(Results that are not dictionaries should be handled correctly):
call ale#lsp#HandleInitResponse(b:conn, {
\ 'jsonrpc': '2.0',
diff --git a/test/test_autocmd_commands.vader b/test/test_autocmd_commands.vader
index 355b4c77..a69333d4 100644
--- a/test/test_autocmd_commands.vader
+++ b/test/test_autocmd_commands.vader
@@ -49,6 +49,7 @@ Before:
Save g:ale_lint_on_save
Save g:ale_lint_on_text_changed
Save g:ale_pattern_options_enabled
+ Save g:ale_hover_cursor
" Turn everything on by defaul for these tests.
let g:ale_completion_enabled = 1
@@ -61,6 +62,7 @@ Before:
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 1
let g:ale_pattern_options_enabled = 1
+ let g:ale_hover_cursor = 1
After:
delfunction CheckAutocmd
@@ -84,6 +86,7 @@ Execute (All events should be set up when everything is on):
\ 'BufWinEnter * call ale#events#LintOnEnter(str2nr(expand(''<abuf>'')))',
\ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
\ 'CursorHold * if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarningWithDelay() | endif',
+ \ 'CursorHold if exists(''*ale#lsp#Send'') | call ale#hover#ShowTruncatedMessageAtCursor() | endif',
\ 'CursorMoved * if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarningWithDelay() | endif',
\ 'FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''<abuf>'')))',
\ 'FileType * call ale#events#FileTypeEvent( str2nr(expand(''<abuf>'')), expand(''<amatch>''))',
@@ -95,9 +98,30 @@ Execute (All events should be set up when everything is on):
\ CheckAutocmd('ALEEvents')
Execute (Only the required events should be bound even if various settings are off):
+ let g:ale_enabled = 1
+ let g:ale_completion_enabled = 0
+ let g:ale_echo_cursor = 0
+ let g:ale_fix_on_save = 0
+ let g:ale_lint_on_enter = 0
+ let g:ale_lint_on_filetype_changed = 0
+ let g:ale_lint_on_insert_leave = 0
+ let g:ale_lint_on_save = 0
+ let g:ale_lint_on_text_changed = 0
+ let g:ale_pattern_options_enabled = 0
+ let g:ale_hover_cursor = 0
+
+ AssertEqual
+ \ [
+ \ 'BufEnter * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))',
+ \ 'BufReadPost * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))',
+ \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
+ \ ],
+ \ CheckAutocmd('ALEEvents')
+
+Execute (The cursor hoever event should be enabled with g:ale_hover_cursor = 1):
+ let g:ale_enabled = 1
let g:ale_completion_enabled = 0
let g:ale_echo_cursor = 0
- let g:ale_enabled = 0
let g:ale_fix_on_save = 0
let g:ale_lint_on_enter = 0
let g:ale_lint_on_filetype_changed = 0
@@ -105,12 +129,14 @@ Execute (Only the required events should be bound even if various settings are o
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 0
let g:ale_pattern_options_enabled = 0
+ let g:ale_hover_cursor = 1
AssertEqual
\ [
\ 'BufEnter * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))',
\ 'BufReadPost * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))',
\ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
+ \ 'CursorHold * if exists(''*ale#lsp#Send'') | call ale#hover#ShowTruncatedMessageAtCursor() | endif',
\ ],
\ CheckAutocmd('ALEEvents')
diff --git a/test/test_cpp_project/.astylerc b/test/test_cpp_project/.astylerc
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test_cpp_project/.astylerc
diff --git a/test/test_cpp_project/dummy.cpp b/test/test_cpp_project/dummy.cpp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test_cpp_project/dummy.cpp
diff --git a/test/test_filetype_linter_defaults.vader b/test/test_filetype_linter_defaults.vader
index 9c40cb23..842cc394 100644
--- a/test/test_filetype_linter_defaults.vader
+++ b/test/test_filetype_linter_defaults.vader
@@ -32,7 +32,7 @@ Execute(The defaults for the help filetype should be correct):
AssertEqual [], GetLinterNames('help')
Execute(The defaults for the python filetype should be correct):
- AssertEqual ['flake8', 'mypy', 'pylint'], GetLinterNames('python')
+ AssertEqual ['flake8', 'mypy', 'pylint', 'pyright'], GetLinterNames('python')
let g:ale_linters_explicit = 1
@@ -61,7 +61,7 @@ Execute(The defaults for the zsh filetype should be correct):
Execute(The defaults for the verilog filetype should be correct):
" This filetype isn't configured with default, so we can test loading all
" available linters with this.
- AssertEqual ['iverilog', 'verilator', 'vlog', 'xvlog'], GetLinterNames('verilog')
+ AssertEqual ['hdl-checker', 'iverilog', 'verilator', 'vlog', 'xvlog'], GetLinterNames('verilog')
let g:ale_linters_explicit = 1
diff --git a/test/test_hdl_checker_options.vader b/test/test_hdl_checker_options.vader
new file mode 100644
index 00000000..4bee0f55
--- /dev/null
+++ b/test/test_hdl_checker_options.vader
@@ -0,0 +1,78 @@
+Before:
+ call ale#assert#SetUpLinterTest('vhdl', 'hdl_checker')
+
+ Save g:ale_hdl_checker_config_file
+ Save g:ale_hdl_checker_options
+
+ let g:default_config_file = has('unix') ? '.hdl_checker.config' : '_hdl_checker.config'
+
+After:
+ Restore
+ call ale#assert#TearDownLinterTest()
+ unlet! g:default_config_file
+
+Execute(Get default initialization dict):
+ AssertEqual
+ \ {'project_file': g:default_config_file},
+ \ ale#handlers#hdl_checker#GetInitOptions(bufnr(''))
+
+Execute(Get custom initialization dict):
+ let g:ale_hdl_checker_config_file = 'some_file_name'
+
+ AssertEqual
+ \ {'project_file': 'some_file_name'},
+ \ ale#handlers#hdl_checker#GetInitOptions(bufnr(''))
+
+Execute(Get the checker command without extra user parameters):
+ AssertEqual
+ \ ale#Escape('hdl_checker') . ' --lsp',
+ \ ale#handlers#hdl_checker#GetCommand(bufnr(''))
+
+Execute(Get the checker command with user configured parameters):
+ let g:ale_hdl_checker_options = '--log-level DEBUG'
+
+ AssertEqual
+ \ ale#Escape('hdl_checker') . ' --lsp --log-level DEBUG',
+ \ ale#handlers#hdl_checker#GetCommand(bufnr(''))
+
+Execute(Customize executable):
+ let g:ale_hdl_checker_executable = '/some/other/path'
+ AssertEqual
+ \ ale#Escape('/some/other/path') . ' --lsp',
+ \ ale#handlers#hdl_checker#GetCommand(bufnr(''))
+
+Execute(Get project root based on .git):
+ call ale#test#SetFilename('hdl_server/with_git/files/foo.vhd')
+ " Create .git file
+ silent! call mkdir(g:dir . '/hdl_server/with_git/.git')
+ AssertNotEqual '', glob(g:dir . '/hdl_server/with_git/.git')
+
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/hdl_server/with_git'),
+ \ ale#handlers#hdl_checker#GetProjectRoot(bufnr(''))
+
+Execute(Get project root based on config file):
+ call ale#test#SetFilename('hdl_server/with_config_file/foo.vhd')
+
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/hdl_server/with_config_file'),
+ \ ale#handlers#hdl_checker#GetProjectRoot(bufnr(''))
+
+Execute(Return no project root if neither .git or config file are found):
+ let g:call_count = 0
+
+ " Mock this command to avoid the test to find ale's own .git folder
+ function! ale#handlers#hdl_checker#IsDotGit(path) abort
+ let g:call_count += 1
+ return 0
+ endfunction
+
+ call ale#test#SetFilename('hdl_server/foo.vhd')
+
+ AssertEqual
+ \ '',
+ \ ale#handlers#hdl_checker#GetProjectRoot(bufnr(''))
+
+ AssertEqual g:call_count, 1
+
+ unlet! g:call_count
diff --git a/test/test_hover.vader b/test/test_hover.vader
index 917694a2..8b4cf7bd 100644
--- a/test/test_hover.vader
+++ b/test/test_hover.vader
@@ -133,6 +133,12 @@ Execute(LSP hover responses with markup content should be handled):
AssertEqual ['markup'], g:echo_list
AssertEqual {}, ale#hover#GetMap()
+Execute(LSP hover responses with markup content missing values should be handled):
+ call HandleValidLSPResult({'contents': {'kind': 'something'}})
+
+ AssertEqual [], g:echo_list
+ AssertEqual {}, ale#hover#GetMap()
+
Execute(LSP hover response with lists of strings should be handled):
call HandleValidLSPResult({'contents': [
\ "foo\n",
@@ -145,6 +151,7 @@ Execute(LSP hover response with lists of strings should be handled):
Execute(LSP hover response with lists of strings and marked strings should be handled):
call HandleValidLSPResult({'contents': [
\ {'language': 'rust', 'value': 'foo'},
+ \ {'language': 'foobar'},
\ "bar\n",
\]})
diff --git a/test/test_rename.vader b/test/test_rename.vader
index 3600df59..34d9e32e 100644
--- a/test/test_rename.vader
+++ b/test/test_rename.vader
@@ -327,6 +327,115 @@ Execute(Code actions from LSP should be handled):
\ ],
\ g:code_actions
+Execute(DocumentChanges from LSP should be handled):
+ call ale#rename#HandleLSPResponse(1, {
+ \ 'id': 3,
+ \ 'result': {
+ \ 'documentChanges': [
+ \ {
+ \ 'textDocument': {
+ \ 'version': 1.0,
+ \ 'uri': 'file:///foo/bar/file1.ts',
+ \ },
+ \ 'edits': [
+ \ {
+ \ 'range': {
+ \ 'start': {
+ \ 'line': 1,
+ \ 'character': 2,
+ \ },
+ \ 'end': {
+ \ 'line': 3,
+ \ 'character': 4,
+ \ },
+ \ },
+ \ 'newText': 'bla123',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \})
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'description': 'rename',
+ \ 'changes': [
+ \ {
+ \ 'fileName': '/foo/bar/file1.ts',
+ \ 'textChanges': [
+ \ {
+ \ 'start': {
+ \ 'line': 2,
+ \ 'offset': 3,
+ \ },
+ \ 'end': {
+ \ 'line': 4,
+ \ 'offset': 5,
+ \ },
+ \ 'newText': 'bla123',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ }
+ \ ],
+ \ g:code_actions
+
+Execute(Single DocumentChange from LSP should be handled):
+ call ale#rename#HandleLSPResponse(1, {
+ \ 'id': 3,
+ \ 'result': {
+ \ 'documentChanges': {
+ \ 'textDocument': {
+ \ 'version': 1.0,
+ \ 'uri': 'file:///foo/bar/file1.ts',
+ \ },
+ \ 'edits': [
+ \ {
+ \ 'range': {
+ \ 'start': {
+ \ 'line': 1,
+ \ 'character': 2,
+ \ },
+ \ 'end': {
+ \ 'line': 3,
+ \ 'character': 4,
+ \ },
+ \ },
+ \ 'newText': 'bla123',
+ \ },
+ \ ],
+ \ },
+ \ },
+ \})
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'description': 'rename',
+ \ 'changes': [
+ \ {
+ \ 'fileName': '/foo/bar/file1.ts',
+ \ 'textChanges': [
+ \ {
+ \ 'start': {
+ \ 'line': 2,
+ \ 'offset': 3,
+ \ },
+ \ 'end': {
+ \ 'line': 4,
+ \ 'offset': 5,
+ \ },
+ \ 'newText': 'bla123',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ }
+ \ ],
+ \ g:code_actions
Execute(LSP should perform no action when no result):
call ale#rename#HandleLSPResponse(1, {
\ 'id': 3,