From 04190cbcfe1b1b0681e3c9098b27633c2fc7c870 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 8 Jun 2017 13:52:29 +0100 Subject: #517 Support linter settings needed for LSP, undocumented for now --- test/test_linter_defintion_processing.vader | 71 +++++++++++++++++++++++++++++ test/test_linter_retrieval.vader | 6 +-- 2 files changed, 74 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader index 09566557..9c880c20 100644 --- a/test/test_linter_defintion_processing.vader +++ b/test/test_linter_defintion_processing.vader @@ -365,3 +365,74 @@ Execute(PreProcess should accept `aliases` lists): let g:linter.aliases = ['foo', 'bar'] AssertEqual ['foo', 'bar'], ale#linter#PreProcess(g:linter).aliases + +Execute(PreProcess should accept tsserver LSP configuration): + let g:linter = { + \ 'name': 'x', + \ 'executable': 'x', + \ 'lsp': 'tsserver', + \ 'callback': 'x', + \} + + AssertEqual 'tsserver', ale#linter#PreProcess(g:linter).lsp + + call remove(g:linter, 'executable') + let g:linter.executable_callback = 'X' + + call ale#linter#PreProcess(g:linter).lsp + +Execute(PreProcess should complain about commands being set for LSP configurations): + let g:linter = { + \ 'name': 'x', + \ 'executable': 'x', + \ 'lsp': 'tsserver', + \ 'command': 'x', + \ 'callback': 'x', + \} + + AssertThrows call ale#linter#PreProcess(g:linter) + AssertEqual '`command` and `command_callback` and `command_chain` cannot be used when `lsp` is set', g:vader_exception + + call remove(g:linter, 'command') + let g:linter.command_callback = 'X' + + AssertThrows call ale#linter#PreProcess(g:linter) + AssertEqual '`command` and `command_callback` and `command_chain` cannot be used when `lsp` is set', g:vader_exception + + call remove(g:linter, 'command_callback') + let g:linter.command_chain = [] + + AssertThrows call ale#linter#PreProcess(g:linter) + AssertEqual '`command` and `command_callback` and `command_chain` cannot be used when `lsp` is set', g:vader_exception + +Execute(PreProcess should accept LSP server configurations): + let g:linter = { + \ 'name': 'x', + \ 'lsp': 'lsp', + \ 'callback': 'x', + \ 'address_callback': 'X', + \} + + AssertEqual 'lsp', ale#linter#PreProcess(g:linter).lsp + +Execute(PreProcess should require an address_callback for LSP server configurations): + let g:linter = { + \ 'name': 'x', + \ 'lsp': 'lsp', + \ 'callback': 'x', + \} + + AssertThrows call ale#linter#PreProcess(g:linter) + AssertEqual '`address_callback` must be defined for getting the LSP address', g:vader_exception + +Execute(PreProcess should complain about address_callback for non-LSP linters): + let g:linter = { + \ 'name': 'x', + \ 'callback': 'SomeFunction', + \ 'executable': 'echo', + \ 'command': 'echo', + \ 'address_callback': 'X', + \} + + AssertThrows call ale#linter#PreProcess(g:linter) + AssertEqual '`address_callback` cannot be used when lsp != ''lsp''', g:vader_exception diff --git a/test/test_linter_retrieval.vader b/test/test_linter_retrieval.vader index 39258be1..480d4f0c 100644 --- a/test/test_linter_retrieval.vader +++ b/test/test_linter_retrieval.vader @@ -1,8 +1,8 @@ Before: Save g:ale_linters, g:ale_linter_aliases - let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0, 'aliases': []} - let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1, 'aliases': []} + let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': ''} + let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1, 'aliases': [], 'lsp': ''} call ale#linter#Reset() After: @@ -105,4 +105,4 @@ Execute (The local alias option shouldn't completely replace the global one): AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1') Execute (Linters should be loaded from disk appropriately): - AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': []}], ale#linter#Get('testft') + AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': ''}], ale#linter#Get('testft') -- cgit v1.2.3