diff options
author | Jerko Steiner <jerko.steiner@gmail.com> | 2019-10-22 16:40:27 -0500 |
---|---|---|
committer | Jerko Steiner <jerko.steiner@gmail.com> | 2019-10-22 16:40:27 -0500 |
commit | 463deedc2998ecf864bb479f07e87aa4e83e3030 (patch) | |
tree | 34f72b8b639987de68050e9fa42ba1e2f0289f35 /test | |
parent | 40890cfcf38a91e75176d39748a7e4ccb24aeb6b (diff) | |
parent | 67d0ccc398ca7650bb2c774a94d098bee3049169 (diff) | |
download | ale-463deedc2998ecf864bb479f07e87aa4e83e3030.zip |
Merge branch 'master' into do-not-save-on-autoimport
Diffstat (limited to 'test')
-rw-r--r-- | test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json (renamed from test/command_callback/clangd_paths/compile_commands.json) | 0 | ||||
-rw-r--r-- | test/command_callback/clangd_paths/with_compile_commands/compile_commands.json | 0 | ||||
-rw-r--r-- | test/command_callback/test_c_clangd_command_callbacks.vader | 31 | ||||
-rw-r--r-- | test/command_callback/test_nimlsp_command_callback.vader | 12 | ||||
-rw-r--r-- | test/completion/test_completion_events.vader | 6 | ||||
-rw-r--r-- | test/completion/test_lsp_completion_messages.vader | 2 | ||||
-rw-r--r-- | test/lsp/test_handling_window_requests.vader | 94 | ||||
-rw-r--r-- | test/nim-test-files/with-git/src/source.nim | 0 | ||||
-rw-r--r-- | test/sign/test_linting_sets_signs.vader | 2 | ||||
-rw-r--r-- | test/sign/test_sign_parsing.vader | 14 | ||||
-rw-r--r-- | test/sign/test_sign_placement.vader | 6 | ||||
-rw-r--r-- | test/test_ale_has.vader | 1 | ||||
-rw-r--r-- | test/test_nimlsp_project_root.vader | 19 |
13 files changed, 169 insertions, 18 deletions
diff --git a/test/command_callback/clangd_paths/compile_commands.json b/test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json index e69de29b..e69de29b 100644 --- a/test/command_callback/clangd_paths/compile_commands.json +++ b/test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json diff --git a/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json b/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json diff --git a/test/command_callback/test_c_clangd_command_callbacks.vader b/test/command_callback/test_c_clangd_command_callbacks.vader index dc52097d..555122f6 100644 --- a/test/command_callback/test_c_clangd_command_callbacks.vader +++ b/test/command_callback/test_c_clangd_command_callbacks.vader @@ -4,31 +4,52 @@ Before: Save &filetype let &filetype = 'c' + Save b:ale_c_clangd_options + Save b:ale_c_build_dir + Save b:ale_c_build_dir_names + Save b:ale_c_parse_compile_commands + + let b:command_tail = ' -x c' + After: + unlet! b:command_tail + call ale#assert#TearDownLinterTest() Execute(The language string should be correct): AssertLSPLanguage 'c' Execute(The default executable should be correct): - AssertLinter 'clangd', ale#Escape('clangd') + AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail Execute(The project root should be detected correctly): call ale#test#SetFilename(tempname() . '/dummy.c') AssertLSPProject '' - call ale#test#SetFilename('clangd_paths/dummy.c') + call ale#test#SetFilename('clangd_paths/with_compile_commands/dummy.c') - AssertLSPProject ale#path#Simplify(g:dir . '/clangd_paths') + AssertLSPProject ale#path#Simplify(g:dir . '/clangd_paths/with_compile_commands') Execute(The executable should be configurable): let g:ale_c_clangd_executable = 'foobar' - AssertLinter 'foobar', ale#Escape('foobar') + AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail Execute(The options should be configurable): let b:ale_c_clangd_options = '-compile-commands-dir=foo' - AssertLinter 'clangd', ale#Escape('clangd') . ' ' . b:ale_c_clangd_options + AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail . ' ' . b:ale_c_clangd_options + +Execute(The compile command database should be detected correctly): + call ale#test#SetFilename('clangd_paths/with_build_dir/dummy_src/dummy.c') + + let b:ale_c_clangd_options = '' + let b:ale_c_build_dir = '' + let b:ale_c_build_dir_names = ['unusual_build_dir_name'] + let b:ale_c_parse_compile_commands = 1 + + AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail + \ . ' -compile-commands-dir=' + \ . ale#Escape(ale#path#Simplify(g:dir . '/clangd_paths/with_build_dir/unusual_build_dir_name')) diff --git a/test/command_callback/test_nimlsp_command_callback.vader b/test/command_callback/test_nimlsp_command_callback.vader new file mode 100644 index 00000000..c109deef --- /dev/null +++ b/test/command_callback/test_nimlsp_command_callback.vader @@ -0,0 +1,12 @@ +Before: + call ale#assert#SetUpLinterTest('nim', 'nimlsp') + +After: + call ale#assert#TearDownLinterTest() + +Execute(It does not set nim sources by default): + AssertLinter 'nimlsp', ale#Escape('nimlsp') + +Execute(Sets nimlsp and escapes sources from g:ale_nim_nimlsp_nim_sources): + let g:ale_nim_nimlsp_nim_sources = '/path/to /Nim' + AssertLinter 'nimlsp', ale#Escape('nimlsp') . ' ' . ale#Escape('/path/to /Nim') diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index a6dcdac4..90a2e3a2 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -432,6 +432,12 @@ Execute(HandleUserData should call ale#code_action#HandleCodeAction): \}) AssertEqual g:handle_code_action_called, 2 + let b:ale_completion_info = {'source': 'ale-callback'} + call ale#completion#HandleUserData({ + \ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}' + \}) + AssertEqual g:handle_code_action_called, 3 + Execute(ale#code_action#HandleCodeAction should not be called when when source is not ALE): call MockHandleCodeAction() let b:ale_completion_info = {'source': 'syntastic'} diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader index b997ac86..4b7392f5 100644 --- a/test/completion/test_lsp_completion_messages.vader +++ b/test/completion/test_lsp_completion_messages.vader @@ -190,10 +190,8 @@ Execute(The right message sent to the tsserver LSP when the first completion mes \ 'source': '/path/to/foo.ts', \ }, { \ 'name': 'FooBar', - \ 'source': '', \ }, { \ 'name': 'frazzle', - \ 'source': '', \ }], \ 'offset': 1, \ 'line': 1, diff --git a/test/lsp/test_handling_window_requests.vader b/test/lsp/test_handling_window_requests.vader new file mode 100644 index 00000000..551d5975 --- /dev/null +++ b/test/lsp/test_handling_window_requests.vader @@ -0,0 +1,94 @@ +Before: + let g:expr_list = [] + let g:linter_name = 'some_linter' + let g:format = '%severity%:%linter%: %s' + " Get the default value to restore it + let g:default_severity = g:ale_lsp_show_message_severity + let g:ale_lsp_show_message_severity = 'information' + + function! ale#util#ShowMessage(expr) abort + call add(g:expr_list, a:expr) + endfunction + +After: + unlet! g:expr_list + unlet! g:linter_name + unlet! g:format + let g:ale_lsp_show_message_severity = g:default_severity + unlet! g:default_severity + +Execute(ale#lsp_window#HandleShowMessage() should only show errors when severity is set to "error"): + let g:ale_lsp_show_message_severity = 'error' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual ['Error:some_linter: an error'], g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should only show errors and warnings when severity is set to "warning"): + let g:ale_lsp_show_message_severity = 'warning' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual ['Error:some_linter: an error', 'Warning:some_linter: a warning'], g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should only show errors, warnings and infos when severity is set to "information"): + let g:ale_lsp_show_message_severity = 'information' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning', + \ 'Info:some_linter: an info'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should only show errors, warnings and infos when severity is set to "info"): + let g:ale_lsp_show_message_severity = 'info' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning', + \ 'Info:some_linter: an info'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should show all messages is severity is set to "log"): + let g:ale_lsp_show_message_severity = 'log' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning', + \ 'Info:some_linter: an info', + \ 'Log:some_linter: a log'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should not show anything if severity is configured as disabled): + let g:ale_lsp_show_message_severity = 'disabled' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [], g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should use "warning" when severity is set to an invalid value): + let g:ale_lsp_show_message_severity = 'foo' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should escape quotes on messages): + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':"this is an 'info'"}) + AssertEqual ['Info:some_linter: this is an ''info'''], g:expr_list diff --git a/test/nim-test-files/with-git/src/source.nim b/test/nim-test-files/with-git/src/source.nim new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/nim-test-files/with-git/src/source.nim diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader index bb042679..60ae0a83 100644 --- a/test/sign/test_linting_sets_signs.vader +++ b/test/sign/test_linting_sets_signs.vader @@ -32,7 +32,7 @@ Before: function! CollectSigns() redir => l:output - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) silent exec 'sign place group=ale' else silent exec 'sign place' diff --git a/test/sign/test_sign_parsing.vader b/test/sign/test_sign_parsing.vader index 8fb7f8e0..157ff2f4 100644 --- a/test/sign/test_sign_parsing.vader +++ b/test/sign/test_sign_parsing.vader @@ -1,5 +1,5 @@ Execute (Parsing English signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[9, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([ @@ -16,7 +16,7 @@ Execute (Parsing English signs should work): endif Execute (Parsing Russian signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[1, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([' строка=1 id=1000001 группа=ale имя=ALEErrorSign']) @@ -27,7 +27,7 @@ Execute (Parsing Russian signs should work): endif Execute (Parsing Japanese signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[1, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign']) @@ -38,7 +38,7 @@ Execute (Parsing Japanese signs should work): endif Execute (Parsing Spanish signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[12, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' línea=12 id=1000001 grupo=ale nombre=ALEWarningSign']) @@ -49,7 +49,7 @@ Execute (Parsing Spanish signs should work): endif Execute (Parsing Italian signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[1, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' riga=1 id=1000001, gruppo=ale nome=ALEWarningSign']) @@ -60,7 +60,7 @@ Execute (Parsing Italian signs should work): endif Execute (Parsing German signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[235, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([' Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign']) @@ -71,7 +71,7 @@ Execute (Parsing German signs should work): endif Execute (The sign parser should indicate if the dummy sign is set): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [1, [[1, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([ diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader index 97bd9302..80153b22 100644 --- a/test/sign/test_sign_placement.vader +++ b/test/sign/test_sign_placement.vader @@ -68,7 +68,7 @@ Before: function! ParseSigns() redir => l:output - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) silent sign place group=ale else silent sign place @@ -152,7 +152,7 @@ Execute(The current signs should be set for running a job): \ ParseSigns() Execute(Loclist items with sign_id values should be kept): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000348 group=ale line=15 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000349 group=ale line=16 name=ALEWarningSign buffer=' . bufnr('') @@ -297,7 +297,7 @@ Execute(No exceptions should be thrown when setting signs for invalid buffers): Execute(Signs should be removed when lines have multiple sign IDs on them): " We can fail to remove signs if there are multiple signs on one line, " say after deleting lines in Vim, etc. - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000348 group=ale line=3 name=ALEWarningSign buffer=' . bufnr('') exec 'sign place 1000349 group=ale line=10 name=ALEErrorSign buffer=' . bufnr('') diff --git a/test/test_ale_has.vader b/test/test_ale_has.vader index b2df01fe..b8a99103 100644 --- a/test/test_ale_has.vader +++ b/test/test_ale_has.vader @@ -1,4 +1,5 @@ Execute(Checks for versions below the current version should succeed): + AssertEqual 1, ale#Has('ale-2.6.0') AssertEqual 1, ale#Has('ale-2.5.0') AssertEqual 1, ale#Has('ale-2.4.0') AssertEqual 1, ale#Has('ALE-2.2.1') diff --git a/test/test_nimlsp_project_root.vader b/test/test_nimlsp_project_root.vader new file mode 100644 index 00000000..e7027575 --- /dev/null +++ b/test/test_nimlsp_project_root.vader @@ -0,0 +1,19 @@ +Before: + runtime ale_linters/nim/nimlsp.vim + call ale#test#SetDirectory('/testplugin/test') + +After: + if isdirectory(g:dir . '/.git') + call delete(g:dir . '/.git', 'd') + endif + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + + +Execute(Detect root of nim project with .git/ correctly): + call ale#test#SetFilename('nim-test-files/with-git/src/source.nim') + call mkdir(g:dir . '/.git') + AssertEqual + \ ale#path#Simplify(g:dir), + \ ale_linters#nim#nimlsp#GetProjectRoot(bufnr('')) |