mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-10 13:32:34 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
0
test/command_callback/hdl_server/foo.vhd
Normal file
0
test/command_callback/hdl_server/foo.vhd
Normal file
1
test/command_callback/hdl_server/with_git/files/foo.vhd
Normal file
1
test/command_callback/hdl_server/with_git/files/foo.vhd
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
@@ -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') }
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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') }
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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') }
|
||||
|
||||
116
test/command_callback/test_pyright_command_callback.vader
Normal file
116
test/command_callback/test_pyright_command_callback.vader
Normal file
@@ -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,
|
||||
\ },
|
||||
\}
|
||||
@@ -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',
|
||||
\ },
|
||||
\ ],
|
||||
\ },
|
||||
\ ],
|
||||
\ },
|
||||
\ })
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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(''))
|
||||
|
||||
@@ -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;',
|
||||
\ ' ^',
|
||||
\ ])
|
||||
|
||||
@@ -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',
|
||||
\ ])
|
||||
|
||||
@@ -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"]'
|
||||
\ ])
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,9 @@ 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_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,6 +108,7 @@ 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 = 0
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
@@ -114,6 +118,28 @@ Execute (Only the required events should be bound even if various settings are o
|
||||
\ ],
|
||||
\ 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_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 = 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')
|
||||
|
||||
Execute (g:ale_lint_on_text_changed = 1 bind both events):
|
||||
let g:ale_lint_on_text_changed = 1
|
||||
|
||||
|
||||
0
test/test_cpp_project/.astylerc
Normal file
0
test/test_cpp_project/.astylerc
Normal file
0
test/test_cpp_project/dummy.cpp
Normal file
0
test/test_cpp_project/dummy.cpp
Normal file
@@ -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
|
||||
|
||||
|
||||
78
test/test_hdl_checker_options.vader
Normal file
78
test/test_hdl_checker_options.vader
Normal file
@@ -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
|
||||
@@ -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",
|
||||
\]})
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user