diff options
Diffstat (limited to 'test/lsp')
-rw-r--r-- | test/lsp/test_did_save_event.vader | 4 | ||||
-rw-r--r-- | test/lsp/test_engine_lsp_response_handling.vader | 56 | ||||
-rw-r--r-- | test/lsp/test_lsp_command_formatting.vader | 10 | ||||
-rw-r--r-- | test/lsp/test_lsp_custom_request.vader | 1 | ||||
-rw-r--r-- | test/lsp/test_lsp_startup.vader | 10 |
5 files changed, 66 insertions, 15 deletions
diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader index bdea6d98..1d811363 100644 --- a/test/lsp/test_did_save_event.vader +++ b/test/lsp/test_did_save_event.vader @@ -33,8 +33,8 @@ Before: \ 'lsp': 'stdio', \ 'command': 'cat - > /dev/null', \ 'executable': has('win32') ? 'cmd' : 'echo', - \ 'language_callback': 'LanguageCallback', - \ 'project_root_callback': 'ProjectRootCallback', + \ 'language': function('LanguageCallback'), + \ 'project_root': function('ProjectRootCallback'), \ }) let g:ale_linters = {'foobar': ['dummy_linter']} diff --git a/test/lsp/test_engine_lsp_response_handling.vader b/test/lsp/test_engine_lsp_response_handling.vader index 9abfa087..8261f1da 100644 --- a/test/lsp/test_engine_lsp_response_handling.vader +++ b/test/lsp/test_engine_lsp_response_handling.vader @@ -44,9 +44,21 @@ After: Given foobar(An empty file): Execute(tsserver syntax error responses should be handled correctly): runtime ale_linters/typescript/tsserver.vim - call ale#test#SetFilename('filename.ts') + + if has('win32') + call ale#test#SetFilename('filename,[]^$.ts') + else + call ale#test#SetFilename('filename*?,{}[]^$.ts') + endif + call ale#engine#InitBufferInfo(bufnr('')) + if has('win32') + AssertEqual 'filename,[]^$.ts', expand('%:p:t') + else + AssertEqual 'filename*?,{}[]^$.ts', expand('%:p:t') + endif + " When we get syntax errors and no semantic errors, we should keep the " syntax errors. call ale#lsp_linter#HandleLSPResponse(1, { @@ -54,7 +66,7 @@ Execute(tsserver syntax error responses should be handled correctly): \ 'type': 'event', \ 'event': 'syntaxDiag', \ 'body': { - \ 'file': g:dir . '/filename.ts', + \ 'file': expand('%:p'), \ 'diagnostics':[ \ { \ 'start': { @@ -76,7 +88,7 @@ Execute(tsserver syntax error responses should be handled correctly): \ 'type': 'event', \ 'event': 'semanticDiag', \ 'body': { - \ 'file': g:dir . '/filename.ts', + \ 'file': expand('%:p'), \ 'diagnostics':[ \ ], \ }, @@ -104,7 +116,7 @@ Execute(tsserver syntax error responses should be handled correctly): \ 'type': 'event', \ 'event': 'syntaxDiag', \ 'body': { - \ 'file': g:dir . '/filename.ts', + \ 'file': expand('%:p'), \ 'diagnostics':[ \ ], \ }, @@ -146,9 +158,21 @@ Execute(tsserver syntax error responses should be handled correctly): Execute(tsserver semantic error responses should be handled correctly): runtime ale_linters/typescript/tsserver.vim - call ale#test#SetFilename('filename.ts') + + if has('win32') + call ale#test#SetFilename('filename,[]^$.ts') + else + call ale#test#SetFilename('filename*?,{}[]^$.ts') + endif + call ale#engine#InitBufferInfo(bufnr('')) + if has('win32') + AssertEqual 'filename,[]^$.ts', expand('%:p:t') + else + AssertEqual 'filename*?,{}[]^$.ts', expand('%:p:t') + endif + " When we get syntax errors and no semantic errors, we should keep the " syntax errors. call ale#lsp_linter#HandleLSPResponse(1, { @@ -156,7 +180,7 @@ Execute(tsserver semantic error responses should be handled correctly): \ 'type': 'event', \ 'event': 'syntaxDiag', \ 'body': { - \ 'file': g:dir . '/filename.ts', + \ 'file': expand('%:p'), \ 'diagnostics':[ \ ], \ }, @@ -166,7 +190,7 @@ Execute(tsserver semantic error responses should be handled correctly): \ 'type': 'event', \ 'event': 'semanticDiag', \ 'body': { - \ 'file': g:dir . '/filename.ts', + \ 'file': expand('%:p'), \ 'diagnostics':[ \ { \ 'start': { @@ -206,7 +230,7 @@ Execute(tsserver semantic error responses should be handled correctly): \ 'type': 'event', \ 'event': 'semanticDiag', \ 'body': { - \ 'file': g:dir . '/filename.ts', + \ 'file': expand('%:p'), \ 'diagnostics':[ \ ], \ }, @@ -270,15 +294,27 @@ Execute(tsserver errors should mark tsserver no longer active): Execute(LSP diagnostics responses should be handled correctly): let b:ale_linters = ['eclipselsp'] runtime ale_linters/java/eclipselsp.vim - call ale#test#SetFilename('filename.java') + + if has('win32') + call ale#test#SetFilename('filename,[]^$.ts') + else + call ale#test#SetFilename('filename*?,{}[]^$.java') + endif + call ale#engine#InitBufferInfo(bufnr('')) call ale#lsp_linter#SetLSPLinterMap({'1': 'eclipselsp'}) + if has('win32') + AssertEqual 'filename,[]^$.ts', expand('%:p:t') + else + AssertEqual 'filename*?,{}[]^$.java', expand('%:p:t') + endif + call ale#lsp_linter#HandleLSPResponse(1, { \ 'jsonrpc':'2.0', \ 'method':'textDocument/publishDiagnostics', \ 'params': { - \ 'uri':'file://' . g:dir . '/filename.java', + \ 'uri': ale#path#ToURI(expand('%:p')), \ 'diagnostics': [ \ { \ 'range': { diff --git a/test/lsp/test_lsp_command_formatting.vader b/test/lsp/test_lsp_command_formatting.vader index ec3b4120..e99e1dad 100644 --- a/test/lsp/test_lsp_command_formatting.vader +++ b/test/lsp/test_lsp_command_formatting.vader @@ -1,6 +1,10 @@ Before: + Save g:ale_command_wrapper + runtime autoload/ale/lsp.vim + let g:ale_command_wrapper = '' + let g:args = [] " Mock the StartProgram function so we can just capture the arguments. @@ -9,6 +13,8 @@ Before: endfunction After: + Restore + unlet! g:args runtime autoload/ale/lsp.vim @@ -18,8 +24,8 @@ Execute(Command formatting should be applied correctly for LSP linters): \ bufnr(''), \ { \ 'name': 'linter', - \ 'language_callback': {-> 'x'}, - \ 'project_root_callback': {-> '/foo/bar'}, + \ 'language': {-> 'x'}, + \ 'project_root': {-> '/foo/bar'}, \ 'lsp': 'stdio', \ 'executable': has('win32') ? 'cmd': 'true', \ 'command': '%e --foo', diff --git a/test/lsp/test_lsp_custom_request.vader b/test/lsp/test_lsp_custom_request.vader index 04f044af..c8767e59 100644 --- a/test/lsp/test_lsp_custom_request.vader +++ b/test/lsp/test_lsp_custom_request.vader @@ -25,7 +25,6 @@ Before: \ 'name': g:linter_name, \ 'project_root': {b -> g:project_root}, \ 'aliases': [], - \ 'language_callback': {b -> 'cpp'}, \ 'read_buffer': 1, \ 'command': '%e' \ }] diff --git a/test/lsp/test_lsp_startup.vader b/test/lsp/test_lsp_startup.vader index c29690bf..cd9b59dd 100644 --- a/test/lsp/test_lsp_startup.vader +++ b/test/lsp/test_lsp_startup.vader @@ -422,3 +422,13 @@ Execute(Deferred addresses should be handled correctly): Assert Start() call ale#test#FlushJobs() call AssertInitSuccess('foo', 'localhost:1234', 'foobar', '/foo/bar', '') + +Execute(Servers that have crashed should be restarted): + call ale#lsp#Register('foo', '/foo/bar', {}) + call extend(ale#lsp#GetConnections()['foo:/foo/bar'], {'initialized': 1}) + + " Starting the program again should reset initialized to `0`. + call ale#lsp#StartProgram('foo:/foo/bar', 'foobar', 'foobar --start') + + AssertEqual 0, ale#lsp#GetConnections()['foo:/foo/bar']['initialized'] + AssertEqual ['initialize'], map(PopMessages(), 'v:val[''method'']') |