diff options
author | w0rp <devw0rp@gmail.com> | 2018-05-28 16:24:15 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-05-28 16:24:15 +0100 |
commit | d9717147bf735a37adc20f1e8a068806f9ba56be (patch) | |
tree | 831669f35417ebde730fbf090401324dcb7d904e /test | |
parent | 3c55cb087d4f48b16e05c6f60e70a12442003a12 (diff) | |
download | ale-d9717147bf735a37adc20f1e8a068806f9ba56be.zip |
Close #1559 - Report errors from LSP servers in :ALEInfo
Diffstat (limited to 'test')
-rw-r--r-- | test/lsp/test_lsp_error_parsing.vader | 65 | ||||
-rw-r--r-- | test/test_ale_info.vader | 53 | ||||
-rw-r--r-- | test/test_engine_lsp_response_handling.vader | 22 |
3 files changed, 140 insertions, 0 deletions
diff --git a/test/lsp/test_lsp_error_parsing.vader b/test/lsp/test_lsp_error_parsing.vader new file mode 100644 index 00000000..7464b0e7 --- /dev/null +++ b/test/lsp/test_lsp_error_parsing.vader @@ -0,0 +1,65 @@ +Execute(Invalid responses should be handled): + AssertEqual '', ale#lsp#response#GetErrorMessage({}) + AssertEqual '', ale#lsp#response#GetErrorMessage({'error': 0}) + AssertEqual '', ale#lsp#response#GetErrorMessage({'error': {}}) + AssertEqual '', ale#lsp#response#GetErrorMessage({ + \ 'error': { + \ 'code': 0, + \ 'message': 'x', + \ }, + \}) + AssertEqual '', ale#lsp#response#GetErrorMessage({'error': {'code': -32602}}) + AssertEqual '', ale#lsp#response#GetErrorMessage({'error': {'code': -32603}}) + +Execute(Messages without tracebacks should be handled): + AssertEqual 'xyz', ale#lsp#response#GetErrorMessage({ + \ 'error': { + \ 'code': -32602, + \ 'message': 'xyz', + \ }, + \}) + AssertEqual 'abc', ale#lsp#response#GetErrorMessage({ + \ 'error': { + \ 'code': -32603, + \ 'message': 'abc', + \ }, + \}) + +Execute(Invalid traceback data should be tolerated): + AssertEqual 'xyz', ale#lsp#response#GetErrorMessage({ + \ 'error': { + \ 'code': -32602, + \ 'message': 'xyz', + \ 'data': { + \ }, + \ }, + \}) + AssertEqual 'xyz', ale#lsp#response#GetErrorMessage({ + \ 'error': { + \ 'code': -32602, + \ 'message': 'xyz', + \ 'data': { + \ 'traceback': 0, + \ }, + \ }, + \}) + AssertEqual 'xyz', ale#lsp#response#GetErrorMessage({ + \ 'error': { + \ 'code': -32602, + \ 'message': 'xyz', + \ 'data': { + \ 'traceback': [], + \ }, + \ }, + \}) + +Execute(Messages with tracebacks should be handled): + AssertEqual "xyz\n123\n456", ale#lsp#response#GetErrorMessage({ + \ 'error': { + \ 'code': -32602, + \ 'message': 'xyz', + \ 'data': { + \ 'traceback': ['123', '456'], + \ }, + \ }, + \}) diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader index c1ae5a7d..16c04b76 100644 --- a/test/test_ale_info.vader +++ b/test/test_ale_info.vader @@ -12,6 +12,12 @@ Before: Save g:ale_pattern_options_enabled Save g:ale_set_balloons Save g:ale_warn_about_trailing_whitespace + Save g:ale_sign_error + Save g:ale_sign_warning + Save g:ale_sign_info + Save g:ale_sign_style_error + Save g:ale_sign_style_warning + Save g:ale_lsp_error_messages unlet! b:ale_history @@ -26,6 +32,12 @@ Before: let g:ale_pattern_options_enabled = 0 let g:ale_set_balloons = 0 let g:ale_warn_about_trailing_whitespace = 1 + let g:ale_sign_error = '>>' + let g:ale_sign_warning = '--' + let g:ale_sign_info = '--' + let g:ale_sign_style_error = '>>' + let g:ale_sign_style_warning = '--' + let g:ale_lsp_error_messages = {} let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'} let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout'} @@ -469,3 +481,44 @@ Execute (The option for caching failing executable checks should work): \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'), \ '(executable check - failure) TheresNoWayThisIsExecutable', \]) + +Given testft (Empty buffer): +Execute (LSP errors for a linter should be outputted): + let g:ale_lsp_error_messages = {'testlinter1': ['foo', 'bar']} + call ale#linter#Define('testft', g:testlinter1) + + call CheckInfo( + \ [ + \ ' Current Filetype: testft', + \ 'Available Linters: [''testlinter1'']', + \ ' Enabled Linters: [''testlinter1'']', + \ ' Linter Variables:', + \ '', + \ ] + \ + g:globals_lines + \ + [ + \ ' LSP Error Messages:', + \ '', + \ '(Errors for testlinter1)', + \ 'foo', + \ 'bar', + \ ] + \ + g:command_header + \) + +Given testft (Empty buffer): +Execute (LSP errors for other linters shouldn't appear): + let g:ale_lsp_error_messages = {'testlinter2': ['foo']} + call ale#linter#Define('testft', g:testlinter1) + + call CheckInfo( + \ [ + \ ' Current Filetype: testft', + \ 'Available Linters: [''testlinter1'']', + \ ' Enabled Linters: [''testlinter1'']', + \ ' Linter Variables:', + \ '', + \ ] + \ + g:globals_lines + \ + g:command_header + \) diff --git a/test/test_engine_lsp_response_handling.vader b/test/test_engine_lsp_response_handling.vader index b3a45b14..4c6fe637 100644 --- a/test/test_engine_lsp_response_handling.vader +++ b/test/test_engine_lsp_response_handling.vader @@ -1,5 +1,9 @@ Before: Save g:ale_buffer_info + Save g:ale_lsp_error_messages + + unlet! g:ale_lsp_error_messages + call ale#test#SetDirectory('/testplugin/test') After: @@ -7,6 +11,7 @@ After: call ale#test#RestoreDirectory() call ale#linter#Reset() + call ale#engine#ClearLSPData() Execute(tsserver syntax error responses should be handled correctly): runtime ale_linters/typescript/tsserver.vim @@ -153,3 +158,20 @@ Execute(tsserver semantic error responses should be handled correctly): \ [ \ ], \ getloclist(0) + +Execute(LSP errors should be logged in the history): + call ale#engine#SetLSPLinterMap({'347': 'foobar'}) + call ale#engine#HandleLSPResponse(347, { + \ 'jsonrpc': '2.0', + \ 'error': { + \ 'code': -32602, + \ 'message': 'xyz', + \ 'data': { + \ 'traceback': ['123', '456'], + \ }, + \ }, + \}) + + AssertEqual + \ {'foobar': ["xyz\n123\n456"]}, + \ get(g:, 'ale_lsp_error_messages', {}) |