diff options
Diffstat (limited to 'test')
34 files changed, 496 insertions, 183 deletions
diff --git a/test/command_callback/clangd_paths/compile_commands.json b/test/command_callback/clangd_paths/compile_commands.json new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/clangd_paths/compile_commands.json diff --git a/test/command_callback/fortran-fortls-project/.fortls b/test/command_callback/fortran-fortls-project/.fortls new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/test/command_callback/fortran-fortls-project/.fortls @@ -0,0 +1,2 @@ +{ +} diff --git a/test/command_callback/test_c_clangd_command_callbacks.vader b/test/command_callback/test_c_clangd_command_callbacks.vader new file mode 100644 index 00000000..c8c10b67 --- /dev/null +++ b/test/command_callback/test_c_clangd_command_callbacks.vader @@ -0,0 +1,32 @@ +Before: + call ale#assert#SetUpLinterTest('c', 'clangd') + + Save &filetype + let &filetype = 'c' + +After: + 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') + +Execute(The project root should be detected correctly): + AssertLSPProject '' + + call ale#test#SetFilename('clangd_paths/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/clangd_paths') + +Execute(The executable should be configurable): + let g:ale_c_clangd_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +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 + diff --git a/test/command_callback/test_fortran_fortls_callback.vader b/test/command_callback/test_fortran_fortls_callback.vader new file mode 100644 index 00000000..3be7ff4f --- /dev/null +++ b/test/command_callback/test_fortran_fortls_callback.vader @@ -0,0 +1,18 @@ +Before: + call ale#assert#SetUpLinterTest('fortran', 'language_server') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default executable path should be correct): + AssertLinter 'fortls', ale#Escape('fortls') + +Execute(The project root should be detected correctly): + AssertLSPProject '' + + call ale#test#SetFilename('fortran-fortls-project/test.F90') + + AssertLSPProject ale#path#Simplify(g:dir . '/fortran-fortls-project') + +Execute(The language should be correct): + AssertLSPLanguage 'fortran' diff --git a/test/command_callback/test_haskell_cabal_ghc_command_callbacks.vader b/test/command_callback/test_haskell_cabal_ghc_command_callbacks.vader new file mode 100644 index 00000000..650aefa3 --- /dev/null +++ b/test/command_callback/test_haskell_cabal_ghc_command_callbacks.vader @@ -0,0 +1,23 @@ +Before: + Save g:ale_haskell_cabal_ghc_options + + unlet! g:ale_haskell_cabal_ghc_options + unlet! b:ale_haskell_cabal_ghc_options + + runtime ale_linters/haskell/cabal_ghc.vim + +After: + Restore + unlet! b:ale_haskell_cabal_ghc_options + call ale#linter#Reset() + +Execute(The options should be used in the command): + AssertEqual + \ 'cabal exec -- ghc -fno-code -v0 %t', + \ ale_linters#haskell#cabal_ghc#GetCommand(bufnr('')) + + let b:ale_haskell_cabal_ghc_options = 'foobar' + + AssertEqual + \ 'cabal exec -- ghc foobar %t', + \ ale_linters#haskell#cabal_ghc#GetCommand(bufnr('')) diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index f8cf268c..f3e05950 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -32,8 +32,16 @@ Before: endfunction let g:ale_completion_delay = 0 - call ale#completion#Queue() - sleep 1m + + " Run this check a few times, as it can fail randomly. + for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1) + call ale#completion#Queue() + sleep 1m + + if g:get_completions_called is a:expect_success + break + endif + endfor AssertEqual a:expect_success, g:get_completions_called endfunction diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader index 00a174dc..ed0f358b 100644 --- a/test/completion/test_lsp_completion_messages.vader +++ b/test/completion/test_lsp_completion_messages.vader @@ -13,11 +13,11 @@ Before: runtime autoload/ale/lsp.vim let g:message_list = [] + let g:capability_checked = '' let g:Callback = '' + let g:wait_callback_list = [] - function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort - let g:Callback = a:callback - + function! ale#lsp_linter#StartLSP(buffer, linter) abort let l:conn = ale#lsp#NewConnection({}) let l:conn.id = 347 let l:conn.open_documents = {a:buffer : -1} @@ -35,15 +35,28 @@ Before: return 'i' endfunction + function! ale#lsp#WaitForCapability(conn_id, project_root, capability, callback) abort + let g:capability_checked = a:capability + call add(g:wait_callback_list, a:callback) + endfunction + + function! ale#lsp#RegisterCallback(conn_id, callback) abort + let g:Callback = a:callback + endfunction + " Replace the Send function for LSP, so we can monitor calls to it. function! ale#lsp#Send(conn_id, message, ...) abort call add(g:message_list, a:message) + + return 1 endfunction After: Restore unlet! g:message_list + unlet! g:capability_checked + unlet! g:wait_callback_list unlet! g:Callback unlet! b:ale_old_omnifunc unlet! b:ale_old_completopt @@ -84,6 +97,13 @@ Execute(The right message should be sent for the initial tsserver request): call ale#completion#GetCompletions() + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual 1, len(g:wait_callback_list) + AssertEqual 'completion', g:capability_checked + call map(g:wait_callback_list, 'v:val([347, ''/foo/bar''])') + " We should send the right callback. AssertEqual \ 'function(''ale#completion#HandleTSServerResponse'')', @@ -96,9 +116,9 @@ Execute(The right message should be sent for the initial tsserver request): AssertEqual \ { \ 'line_length': 3, - \ 'conn_id': 0, + \ 'conn_id': 347, \ 'column': 3, - \ 'request_id': 0, + \ 'request_id': 1, \ 'line': 1, \ 'prefix': 'fo', \ }, @@ -164,6 +184,13 @@ Execute(The right message should be sent for the initial LSP request): call ale#completion#GetCompletions() + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual 1, len(g:wait_callback_list) + AssertEqual 'completion', g:capability_checked + call map(g:wait_callback_list, 'v:val([347, ''/foo/bar''])') + " We should send the right callback. AssertEqual \ 'function(''ale#completion#HandleLSPResponse'')', @@ -192,10 +219,58 @@ Execute(The right message should be sent for the initial LSP request): AssertEqual \ { \ 'line_length': 3, - \ 'conn_id': 0, + \ 'conn_id': 347, \ 'column': 3, - \ 'request_id': 0, + \ 'request_id': 1, \ 'line': 1, \ 'prefix': 'fo', + \ 'completion_filter': 'ale#completion#python#CompletionItemFilter', \ }, \ get(b:, 'ale_completion_info', {}) + +Execute(Two completion requests shouldn't be sent in a row): + call ale#linter#PreventLoading('python') + call ale#linter#Define('python', { + \ 'name': 'foo', + \ 'lsp': 'stdio', + \ 'executable': 'foo', + \ 'command': 'foo', + \ 'project_root_callback': {-> '/foo/bar'}, + \}) + call ale#linter#Define('python', { + \ 'name': 'bar', + \ 'lsp': 'stdio', + \ 'executable': 'foo', + \ 'command': 'foo', + \ 'project_root_callback': {-> '/foo/bar'}, + \}) + let b:ale_linters = ['foo', 'bar'] + + " The cursor position needs to match what was saved before. + call setpos('.', [bufnr(''), 1, 5, 0]) + + call ale#completion#GetCompletions() + + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual 2, len(g:wait_callback_list) + AssertEqual 'completion', g:capability_checked + call map(g:wait_callback_list, 'v:val([347, ''/foo/bar''])') + + " We should only send one completion message for two LSP servers. + AssertEqual + \ [ + \ [1, 'textDocument/didChange', { + \ 'textDocument': { + \ 'uri': ale#path#ToURI(expand('%:p')), + \ 'version': g:ale_lsp_next_version_id - 1, + \ }, + \ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}] + \ }], + \ [0, 'textDocument/completion', { + \ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))}, + \ 'position': {'line': 0, 'character': 3}, + \ }], + \ ], + \ g:message_list diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader index 736353e3..d5a45b54 100644 --- a/test/completion/test_lsp_completion_parsing.vader +++ b/test/completion/test_lsp_completion_parsing.vader @@ -430,10 +430,10 @@ Execute(Should handle Python completion results correctly): \ } \ }) -Execute(Should handle missing detail keys): +Execute(Should handle missing keys): AssertEqual \ [ - \ {'word': 'x', 'menu': '', 'info': 'y', 'kind': 'f', 'icase': 1}, + \ {'word': 'x', 'menu': '', 'info': '', 'kind': 'v', 'icase': 1}, \ ], \ ale#completion#ParseLSPCompletions({ \ 'jsonrpc': '2.0', @@ -443,8 +443,6 @@ Execute(Should handle missing detail keys): \ 'items': [ \ { \ 'label': 'x', - \ 'kind': 3, - \ 'documentation': 'y', \ }, \ ] \ } diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader index 80eda4a0..67b8b212 100644 --- a/test/fix/test_ale_fix.vader +++ b/test/fix/test_ale_fix.vader @@ -458,7 +458,7 @@ Execute(ALEFix should save files on the save event): \ 'nr': -1, \ 'pattern': '', \ 'valid': 1, - \}], getloclist(0) + \}], ale#test#GetLoclistWithoutModule() endif Expect(The buffer should be modified): @@ -497,7 +497,7 @@ Execute(ALEFix should still lint with no linters to be applied): \ 'nr': -1, \ 'pattern': '', \ 'valid': 1, - \}], getloclist(0) + \}], ale#test#GetLoclistWithoutModule() endif Expect(The buffer should be the same): @@ -531,7 +531,7 @@ Execute(ALEFix should still lint when nothing was fixed on save): \ 'nr': -1, \ 'pattern': '', \ 'valid': 1, - \}], getloclist(0) + \}], ale#test#GetLoclistWithoutModule() endif Expect(The buffer should be the same): @@ -552,8 +552,6 @@ Execute(ale#fix#InitBufferData() should set up the correct data): AssertEqual { \ bufnr(''): { \ 'temporary_directory_list': [], - \ 'vars': b:, - \ 'filename': ale#path#Simplify(getcwd() . '/fix_test_file'), \ 'done': 0, \ 'lines_before': ['a', 'b', 'c'], \ 'should_save': 1, diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader index b696ee4b..428135fb 100644 --- a/test/lsp/test_did_save_event.vader +++ b/test/lsp/test_did_save_event.vader @@ -14,7 +14,6 @@ Before: let g:ale_lsp_next_message_id = 1 let g:ale_run_synchronously = 1 let g:message_list = [] - let g:Callback = '' function! LanguageCallback() abort return 'foobar' @@ -34,9 +33,7 @@ Before: \ }) let g:ale_linters = {'foobar': ['dummy_linter']} - function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort - let g:Callback = a:callback - + function! ale#lsp_linter#StartLSP(buffer, linter) abort let l:conn = ale#lsp#NewConnection({}) let l:conn.id = 347 let l:conn.open_documents = {a:buffer : -1} @@ -59,7 +56,6 @@ After: unlet! b:ale_enabled unlet! b:ale_linters - unlet! g:Callback unlet! g:message_list delfunction LanguageCallback diff --git a/test/lsp/test_lsp_command_formatting.vader b/test/lsp/test_lsp_command_formatting.vader index f436397f..9d2c84ee 100644 --- a/test/lsp/test_lsp_command_formatting.vader +++ b/test/lsp/test_lsp_command_formatting.vader @@ -23,15 +23,14 @@ Execute(Command formatting should be applied correctly for LSP linters): \ 'executable': has('win32') ? 'cmd': 'true', \ 'command': '%e --foo', \ }, - \ {->0} \) if has('win32') AssertEqual - \ ['cmd', 'cmd /s/c "cmd --foo"', '/foo/bar'], - \ g:args[:2] + \ ['cmd', 'cmd /s/c "cmd --foo"', {}], + \ g:args else AssertEqual - \ ['true', [&shell, '-c', '''true'' --foo'], '/foo/bar'], - \ g:args[:2] + \ ['true', [&shell, '-c', '''true'' --foo'], {}], + \ g:args endif diff --git a/test/lsp/test_lsp_connections.vader b/test/lsp/test_lsp_connections.vader index 8651d801..ae64eadb 100644 --- a/test/lsp/test_lsp_connections.vader +++ b/test/lsp/test_lsp_connections.vader @@ -2,6 +2,10 @@ Before: let g:ale_lsp_next_message_id = 1 After: + if exists('b:conn') && has_key(b:conn, 'id') + call ale#lsp#RemoveConnectionWithID(b:conn.id) + endif + unlet! b:data unlet! b:conn @@ -223,17 +227,20 @@ Execute(ale#lsp#ReadMessageData() should handle a message with part of a second \ ) Execute(Projects with regular project roots should be registered correctly): - let b:conn = {'projects': {}} - - call ale#lsp#RegisterProject(b:conn, '/foo/bar') + let b:conn = ale#lsp#NewConnection({}) + call ale#lsp#RegisterProject(b:conn.id, '/foo/bar') AssertEqual \ { - \ 'projects': { - \ '/foo/bar': {'initialized': 0, 'message_queue': [], 'init_request_id': 0}, + \ '/foo/bar': { + \ 'root': '/foo/bar', + \ 'initialized': 0, + \ 'message_queue': [], + \ 'capabilities_queue': [], + \ 'init_request_id': 0, \ }, \ }, - \ b:conn + \ b:conn.projects Execute(Projects with regular project roots should be fetched correctly): let b:conn = { @@ -247,17 +254,20 @@ Execute(Projects with regular project roots should be fetched correctly): \ ale#lsp#GetProject(b:conn, '/foo/bar') Execute(Projects with empty project roots should be registered correctly): - let b:conn = {'projects': {}} - - call ale#lsp#RegisterProject(b:conn, '') + let b:conn = ale#lsp#NewConnection({}) + call ale#lsp#RegisterProject(b:conn.id, '') AssertEqual \ { - \ 'projects': { - \ '<<EMPTY>>': {'initialized': 1, 'message_queue': [], 'init_request_id': 0}, + \ '<<EMPTY>>': { + \ 'root': '', + \ 'initialized': 1, + \ 'message_queue': [], + \ 'capabilities_queue': [], + \ 'init_request_id': 0, \ }, \ }, - \ b:conn + \ b:conn.projects Execute(Projects with empty project roots should be fetched correctly): let b:conn = { diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader index 3a7c7f62..45457979 100644 --- a/test/lsp/test_other_initialize_message_handling.vader +++ b/test/lsp/test_other_initialize_message_handling.vader @@ -3,12 +3,20 @@ Before: \ 'initialized': 0, \ 'init_request_id': 3, \ 'message_queue': [], + \ 'capabilities_queue': [], \} let b:conn = { \ 'projects': { \ '/foo/bar': b:project, \ }, + \ 'capabilities': { + \ 'hover': 0, + \ 'references': 0, + \ 'completion': 0, + \ 'completion_trigger_characters': [], + \ 'definition': 0, + \ }, \} After: @@ -27,6 +35,7 @@ Execute(publishDiagnostics messages with files inside project directories should \ 'initialized': 0, \ 'init_request_id': 3, \ 'message_queue': [], + \ 'capabilities_queue': [], \ }, \ b:project @@ -40,6 +49,7 @@ Execute(publishDiagnostics messages with files inside project directories should \ 'initialized': 1, \ 'init_request_id': 3, \ 'message_queue': [], + \ 'capabilities_queue': [], \ }, \ b:project @@ -53,6 +63,7 @@ Execute(Messages with no method and capabilities should initialize projects): \ 'initialized': 1, \ 'init_request_id': 3, \ 'message_queue': [], + \ 'capabilities_queue': [], \ }, \ b:project @@ -64,3 +75,109 @@ Execute(Other messages should not initialize projects): call ale#lsp#HandleOtherInitializeResponses(b:conn, {'result': {'x': {}}}) AssertEqual 0, b:project.initialized + +Execute(Capabilities should bet set up correctly): + call ale#lsp#HandleOtherInitializeResponses(b:conn, { + \ 'jsonrpc': '2.0', + \ 'id': 1, + \ 'result': { + \ 'capabilities': { + \ 'renameProvider': v:true, + \ 'executeCommandProvider': { + \ 'commands': [], + \ }, + \ 'hoverProvider': v:true, + \ 'documentSymbolProvider': v:true, + \ 'documentRangeFormattingProvider': v:true, + \ 'codeLensProvider': { + \ 'resolveProvider': v:false + \ }, + \ 'referencesProvider': v:true, + \ 'textDocumentSync': 2, + \ 'documentFormattingProvider': v:true, + \ 'codeActionProvider': v:true, + \ 'signatureHelpProvider': { + \ 'triggerCharacters': ['(', ','], + \ }, + \ 'completionProvider': { + \ 'triggerCharacters': ['.'], + \ 'resolveProvider': v:false + \ }, + \ 'definitionProvider': v:true, + \ 'experimental': {}, + \ 'documentHighlightProvider': v:true + \ }, + \ }, + \}) + + AssertEqual + \ { + \ 'capabilities': { + \ 'completion_trigger_characters': ['.'], + \ 'completion': 1, + \ 'references': 1, + \ 'hover': 1, + \ 'definition': 1, + \ }, + \ 'message_queue': [], + \ 'projects': { + \ '/foo/bar': { + \ 'initialized': 1, + \ 'message_queue': [], + \ 'capabilities_queue': [], + \ 'init_request_id': 3, + \ }, + \ }, + \ }, + \ b:conn + +Execute(Disabled capabilities should be recognised correctly): + call ale#lsp#HandleOtherInitializeResponses(b:conn, { + \ 'jsonrpc': '2.0', + \ 'id': 1, + \ 'result': { + \ 'capabilities': { + \ 'renameProvider': v:true, + \ 'executeCommandProvider': { + \ 'commands': [], + \ }, + \ 'hoverProvider': v:false, + \ 'documentSymbolProvider': v:true, + \ 'documentRangeFormattingProvider': v:true, + \ 'codeLensProvider': { + \ 'resolveProvider': v:false + \ }, + \ 'referencesProvider': v:false, + \ 'textDocumentSync': 2, + \ 'documentFormattingProvider': v:true, + \ 'codeActionProvider': v:true, + \ 'signatureHelpProvider': { + \ 'triggerCharacters': ['(', ','], + \ }, + \ 'definitionProvider': v:false, + \ 'experimental': {}, + \ 'documentHighlightProvider': v:true + \ }, + \ }, + \}) + + AssertEqual + \ { + \ 'capabilities': { + \ 'completion_trigger_characters': [], + \ 'completion': 0, + \ 'references': 0, + \ 'hover': 0, + \ 'definition': 0, + \ }, + \ 'message_queue': [], + \ 'projects': { + \ '/foo/bar': { + \ 'initialized': 1, + \ 'message_queue': [], + \ 'capabilities_queue': [], + \ 'init_request_id': 3, + \ }, + \ }, + \ }, + \ b:conn diff --git a/test/script/custom-linting-rules b/test/script/custom-linting-rules index 51cf5680..69c4a7a1 100755 --- a/test/script/custom-linting-rules +++ b/test/script/custom-linting-rules @@ -52,12 +52,17 @@ directories=("$@") check_errors() { regex="$1" message="$2" + include_arg='' + + if [ $# -gt 2 ]; then + include_arg="--include $3" + fi for directory in "${directories[@]}"; do while IFS= read -r match; do RETURN_CODE=1 echo "$match $message" - done < <(grep -n "$regex" "$directory"/**/*.vim \ + done < <(grep -n "$regex" $include_arg "$directory"/**/*.vim \ | grep -v 'no-custom-checks' \ | grep -o '^[^:]\+:[0-9]\+' \ | sed 's:^\./::') @@ -75,6 +80,7 @@ if (( FIX_ERRORS )); then done fi +# The arguments are: regex, explanation, [filename_filter] check_errors \ '^function.*) *$' \ 'Function without abort keyword (See :help except-compat)' @@ -95,5 +101,6 @@ check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true" check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false" check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false" check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something" +check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*' exit $RETURN_CODE diff --git a/test/smoke_test.vader b/test/smoke_test.vader index 1cbf512d..2708c86f 100644 --- a/test/smoke_test.vader +++ b/test/smoke_test.vader @@ -35,7 +35,6 @@ After: unlet! g:i unlet! g:results - unlet! g:item unlet! g:expected_results delfunction TestCallback @@ -69,13 +68,7 @@ Execute(Linters should run with the default options): call ale#Lint() call ale#engine#WaitForJobs(2000) - let g:results = getloclist(0) - - for g:item in g:results - if has_key(g:item, 'module') - call remove(g:item, 'module') - endif - endfor + let g:results = ale#test#GetLoclistWithoutModule() if g:results == g:expected_results break @@ -142,7 +135,7 @@ Execute(Linters should run in PowerShell too): \ 'pattern': '', \ 'valid': 1, \ }, - \], getloclist(0) + \], ale#test#GetLoclistWithoutModule() endif Execute(Previous errors should be removed when linters change): @@ -176,13 +169,7 @@ Execute(Previous errors should be removed when linters change): call ale#Lint() call ale#engine#WaitForJobs(2000) - let g:results = getloclist(0) - - for g:item in g:results - if has_key(g:item, 'module') - call remove(g:item, 'module') - endif - endfor + let g:results = ale#test#GetLoclistWithoutModule() if g:results == g:expected_results break diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader index 6434e45f..bc2ebabe 100644 --- a/test/test_ale_lint_command.vader +++ b/test/test_ale_lint_command.vader @@ -66,10 +66,10 @@ Execute(ALELint should run the linters): sleep 1ms endif - if getloclist(0) == g:expected_loclist + if ale#test#GetLoclistWithoutModule() == g:expected_loclist break endif endfor " Check the loclist - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader index 3b3c509c..db891009 100644 --- a/test/test_ale_toggle.vader +++ b/test/test_ale_toggle.vader @@ -115,7 +115,7 @@ Execute(ALEToggle should reset everything and then run again): ALELint " First check that everything is there... - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], @@ -128,7 +128,7 @@ Execute(ALEToggle should reset everything and then run again): " Everything should be cleared. Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed' - AssertEqual [], getloclist(0), 'The loclist was not cleared' + AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared' AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared' AssertEqual [], getmatches(), 'The highlights were not cleared' AssertEqual g:expected_groups, ParseAuGroups() @@ -136,7 +136,7 @@ Execute(ALEToggle should reset everything and then run again): " Toggle ALE on, everything should be set up and run again. ALEToggle - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], @@ -189,16 +189,16 @@ Execute(ALEToggle should skip filename keys and preserve them): Execute(ALEDisable should reset everything and stay disabled): ALELint - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() ALEDisable - AssertEqual [], getloclist(0) + AssertEqual [], ale#test#GetLoclistWithoutModule() AssertEqual 0, g:ale_enabled ALEDisable - AssertEqual [], getloclist(0) + AssertEqual [], ale#test#GetLoclistWithoutModule() AssertEqual 0, g:ale_enabled Execute(ALEEnable should enable ALE and lint again): @@ -206,7 +206,7 @@ Execute(ALEEnable should enable ALE and lint again): ALEEnable - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual 1, g:ale_enabled Execute(ALEReset should reset everything for a buffer): @@ -215,7 +215,7 @@ Execute(ALEReset should reset everything for a buffer): ALELint " First check that everything is there... - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], @@ -227,7 +227,7 @@ Execute(ALEReset should reset everything for a buffer): " Everything should be cleared. Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed' - AssertEqual [], getloclist(0), 'The loclist was not cleared' + AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared' AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared' AssertEqual [], getmatches(), 'The highlights were not cleared' @@ -239,7 +239,7 @@ Execute(ALEToggleBuffer should reset everything and then run again): ALELint " First check that everything is there... - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], @@ -251,14 +251,14 @@ Execute(ALEToggleBuffer should reset everything and then run again): " Everything should be cleared. Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed' - AssertEqual [], getloclist(0), 'The loclist was not cleared' + AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared' AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared' AssertEqual [], getmatches(), 'The highlights were not cleared' " Toggle ALE on, everything should be set up and run again. ALEToggleBuffer - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], @@ -269,11 +269,11 @@ Execute(ALEToggleBuffer should reset everything and then run again): Execute(ALEDisableBuffer should reset everything and stay disabled): ALELint - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() ALEDisableBuffer - AssertEqual [], getloclist(0) + AssertEqual [], ale#test#GetLoclistWithoutModule() AssertEqual 0, b:ale_enabled Execute(ALEEnableBuffer should enable ALE and lint again): @@ -281,7 +281,7 @@ Execute(ALEEnableBuffer should enable ALE and lint again): ALEEnableBuffer - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual 1, b:ale_enabled Execute(ALEEnableBuffer should complain when ALE is disabled globally): @@ -292,7 +292,7 @@ Execute(ALEEnableBuffer should complain when ALE is disabled globally): ALEEnableBuffer redir END - AssertEqual [], getloclist(0) + AssertEqual [], ale#test#GetLoclistWithoutModule() AssertEqual 0, b:ale_enabled AssertEqual 0, g:ale_enabled AssertEqual @@ -305,7 +305,7 @@ Execute(ALEResetBuffer should reset everything for a buffer): ALELint " First check that everything is there... - AssertEqual g:expected_loclist, getloclist(0) + AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule() AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], @@ -317,7 +317,7 @@ Execute(ALEResetBuffer should reset everything for a buffer): " Everything should be cleared. Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed' - AssertEqual [], getloclist(0), 'The loclist was not cleared' + AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared' AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared' AssertEqual [], getmatches(), 'The highlights were not cleared' @@ -326,40 +326,60 @@ Execute(ALEResetBuffer should reset everything for a buffer): Execute(Disabling ALE should disable balloons): " These tests won't run in the console, but we can run them manually in GVim. - if has('balloon_eval') && has('gui_running') || - \ has('balloon_eval_term') && !has('gui_running') + if has('balloon_eval') && has('gui_running') + \|| (has('balloon_eval_term') && !has('gui_running')) call ale#linter#Reset() " Enable balloons, so we can check the expr value. call ale#balloon#Enable() - AssertEqual 1, &ballooneval + if has('balloon_eval') && has('gui_running') + AssertEqual 1, &ballooneval + else + AssertEqual 1, &balloonevalterm + endif + AssertEqual 'ale#balloon#Expr()', &balloonexpr " Toggle ALE off. ALEToggle " The balloon settings should be reset. - AssertEqual 0, &ballooneval + if has('balloon_eval') && has('gui_running') + AssertEqual 0, &ballooneval + else + AssertEqual 0, &balloonevalterm + endif + AssertEqual '', &balloonexpr endif Execute(Enabling ALE should enable balloons if the setting is on): - if has('balloon_eval') && has('gui_running') || - \ has('balloon_eval_term') && !has('gui_running') + if has('balloon_eval') && has('gui_running') + \|| (has('balloon_eval_term') && !has('gui_running')) call ale#linter#Reset() call ale#balloon#Disable() ALEDisable let g:ale_set_balloons = 0 ALEEnable - AssertEqual 0, &ballooneval + if has('balloon_eval') && has('gui_running') + AssertEqual 0, &ballooneval + else + AssertEqual 0, &balloonevalterm + endif + AssertEqual '', &balloonexpr ALEDisable let g:ale_set_balloons = 1 ALEEnable - AssertEqual 1, &ballooneval + if has('balloon_eval') && has('gui_running') + AssertEqual 1, &ballooneval + else + AssertEqual 1, &balloonevalterm + endif + AssertEqual 'ale#balloon#Expr()', &balloonexpr endif diff --git a/test/test_ale_var.vader b/test/test_ale_var.vader index 5f42fe95..419a9983 100644 --- a/test/test_ale_var.vader +++ b/test/test_ale_var.vader @@ -5,8 +5,6 @@ After: unlet! g:ale_some_variable unlet! b:undefined_variable_name - let g:ale_fix_buffer_data = {} - Execute(ale#Var should return global variables): AssertEqual 'abc', ale#Var(bufnr(''), 'some_variable') @@ -24,13 +22,3 @@ Execute(ale#Var should throw exceptions for undefined variables): let b:undefined_variable_name = 'def' AssertThrows call ale#Var(bufnr(''), 'undefined_variable_name') - -Execute(ale#Var return variables from deleted buffers, saved for fixing things): - let g:ale_fix_buffer_data[1347347] = {'vars': {'ale_some_variable': 'def'}} - - AssertEqual 'def', ale#Var(1347347, 'some_variable') - -Execute(ale#Var should return the global variable for unknown variables): - let g:ale_fix_buffer_data = {} - - AssertEqual 'abc', ale#Var(1347347, 'some_variable') diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader index f2a06781..0490dec6 100644 --- a/test/test_c_import_paths.vader +++ b/test/test_c_import_paths.vader @@ -1,8 +1,21 @@ Before: + " Make sure the c.vim file is loaded first. + call ale#c#FindProjectRoot(bufnr('')) + Save g:ale_c_gcc_options Save g:ale_c_clang_options Save g:ale_cpp_gcc_options Save g:ale_cpp_clang_options + Save g:__ale_c_project_filenames + + let g:original_project_filenames = g:__ale_c_project_filenames + + " Remove the .git/HEAD dir for C import paths for these tests. + " The tests run inside of a git repo. + let g:__ale_c_project_filenames = filter( + \ copy(g:__ale_c_project_filenames), + \ 'v:val isnot# ''.git/HEAD''' + \) call ale#test#SetDirectory('/testplugin/test') @@ -14,23 +27,11 @@ Before: After: Restore + unlet! g:original_project_filenames + call ale#test#RestoreDirectory() call ale#linter#Reset() -" Run this only once for this series of tests. The cleanup Execute step -" will run at the bottom of this file. -" -" We need to move .git/HEAD away so we don't match it, as we need to test -" functions which look for .git/HEAD. -Execute(Move .git/HEAD to a temp dir): - let g:temp_head_filename = tempname() - let g:head_filename = findfile('.git/HEAD', ';') - - if !empty(g:head_filename) - call writefile(readfile(g:head_filename, 'b'), g:temp_head_filename, 'b') - call delete(g:head_filename) - endif - Execute(The C GCC handler should include 'include' directories for projects with a Makefile): runtime! ale_linters/c/gcc.vim @@ -239,27 +240,6 @@ Execute(The C++ Clang handler should include root directories for projects with \ . ' -' \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) -Execute(The C++ Clang handler shoud use the include directory based on the .git location): - runtime! ale_linters/cpp/clang.vim - - if !isdirectory(g:dir . '/test_c_projects/git_and_nested_makefiles/.git') - call mkdir(g:dir . '/test_c_projects/git_and_nested_makefiles/.git') - endif - - if !filereadable(g:dir . '/test_c_projects/git_and_nested_makefiles/.git/HEAD') - call writefile([], g:dir . '/test_c_projects/git_and_nested_makefiles/.git/HEAD') - endif - - call ale#test#SetFilename('test_c_projects/git_and_nested_makefiles/src/file.cpp') - - AssertEqual - \ ale#Escape('clang++') - \ . ' -S -x c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/git_and_nested_makefiles/src')) . ' ' - \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/git_and_nested_makefiles/include')) . ' ' - \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) - Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them): runtime! ale_linters/cpp/clangtidy.vim @@ -270,12 +250,3 @@ Execute(The C++ ClangTidy handler should include json folders for projects with \ . ' -checks=' . ale#Escape('*') . ' %s ' \ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/json_project/build')) \ , ale_linters#cpp#clangtidy#GetCommand(bufnr('')) - -Execute(Move .git/HEAD back): - if !empty(g:head_filename) - call writefile(readfile(g:temp_head_filename, 'b'), g:head_filename, 'b') - call delete(g:temp_head_filename) - endif - - unlet! g:temp_head_filename - unlet! g:head_filename diff --git a/test/test_engine_lsp_response_handling.vader b/test/test_engine_lsp_response_handling.vader index 18bad0a1..517d82c0 100644 --- a/test/test_engine_lsp_response_handling.vader +++ b/test/test_engine_lsp_response_handling.vader @@ -68,7 +68,7 @@ Execute(tsserver syntax error responses should be handled correctly): \ 'pattern': '', \ }, \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() " After we get empty syntax errors, we should clear them. call ale#lsp_linter#HandleLSPResponse(1, { @@ -85,7 +85,7 @@ Execute(tsserver syntax error responses should be handled correctly): AssertEqual \ [ \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() Execute(tsserver semantic error responses should be handled correctly): runtime ale_linters/typescript/tsserver.vim @@ -141,7 +141,7 @@ Execute(tsserver semantic error responses should be handled correctly): \ 'pattern': '', \ }, \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() " After we get empty syntax errors, we should clear them. call ale#lsp_linter#HandleLSPResponse(1, { @@ -158,7 +158,7 @@ Execute(tsserver semantic error responses should be handled correctly): AssertEqual \ [ \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() Execute(LSP errors should be logged in the history): call ale#lsp_linter#SetLSPLinterMap({'347': 'foobar'}) diff --git a/test/test_errors_removed_after_filetype_changed.vader b/test/test_errors_removed_after_filetype_changed.vader index afd882b1..651a74f2 100644 --- a/test/test_errors_removed_after_filetype_changed.vader +++ b/test/test_errors_removed_after_filetype_changed.vader @@ -53,7 +53,7 @@ Execute(Error should be removed when the filetype changes to something else we c call ale#Queue(0) sleep 1ms - AssertEqual 1, len(getloclist(0)) + AssertEqual 1, len(ale#test#GetLoclistWithoutModule()) noautocmd let &filetype = 'foobar2' @@ -61,11 +61,11 @@ Execute(Error should be removed when the filetype changes to something else we c sleep 1ms " We should get some items from the second filetype. - AssertEqual 1, len(getloclist(0)) + AssertEqual 1, len(ale#test#GetLoclistWithoutModule()) noautocmd let &filetype = 'xxx' call ale#Queue(0) sleep 1ms - AssertEqual 0, len(getloclist(0)) + AssertEqual 0, len(ale#test#GetLoclistWithoutModule()) diff --git a/test/test_filetype_linter_defaults.vader b/test/test_filetype_linter_defaults.vader index ea4a05fb..4f190226 100644 --- a/test/test_filetype_linter_defaults.vader +++ b/test/test_filetype_linter_defaults.vader @@ -22,7 +22,7 @@ Execute(The defaults for the csh filetype should be correct): AssertEqual [], GetLinterNames('csh') Execute(The defaults for the go filetype should be correct): - AssertEqual ['gofmt', 'golint', 'go vet'], GetLinterNames('go') + AssertEqual ['gofmt', 'golint', 'govet'], GetLinterNames('go') let g:ale_linters_explicit = 1 diff --git a/test/test_find_references.vader b/test/test_find_references.vader index 150e0471..ecced068 100644 --- a/test/test_find_references.vader +++ b/test/test_find_references.vader @@ -3,20 +3,20 @@ Before: call ale#test#SetFilename('dummy.txt') let g:old_filename = expand('%:p') - let g:Callback = 0 + let g:Callback = '' let g:expr_list = [] let g:message_list = [] let g:preview_called = 0 let g:item_list = [] + let g:capability_checked = '' + let g:WaitCallback = v:null runtime autoload/ale/linter.vim runtime autoload/ale/lsp.vim runtime autoload/ale/util.vim runtime autoload/ale/preview.vim - function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort - let g:Callback = a:callback - + function! ale#lsp_linter#StartLSP(buffer, linter) abort let l:conn = ale#lsp#NewConnection({}) let l:conn.id = 347 let l:conn.open_documents = {a:buffer : -1} @@ -29,6 +29,15 @@ Before: \} endfunction + function! ale#lsp#WaitForCapability(conn_id, project_root, capability, callback) abort + let g:capability_checked = a:capability + let g:WaitCallback = a:callback + endfunction + + function! ale#lsp#RegisterCallback(conn_id, callback) abort + let g:Callback = a:callback + endfunction + function! ale#lsp#Send(conn_id, message, root) abort call add(g:message_list, a:message) @@ -50,6 +59,8 @@ After: call ale#test#RestoreDirectory() call ale#linter#Reset() + unlet! g:capability_checked + unlet! g:WaitCallback unlet! g:old_filename unlet! g:Callback unlet! g:message_list @@ -152,6 +163,13 @@ Execute(tsserver reference requests should be sent): ALEFindReferences + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual type(function('type')), type(g:WaitCallback) + AssertEqual 'references', g:capability_checked + call call(g:WaitCallback, [347, '/foo/bar']) + AssertEqual \ 'function(''ale#references#HandleTSServerResponse'')', \ string(g:Callback) @@ -226,6 +244,13 @@ Execute(LSP reference requests should be sent): ALEFindReferences + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual type(function('type')), type(g:WaitCallback) + AssertEqual 'references', g:capability_checked + call call(g:WaitCallback, [347, '/foo/bar']) + AssertEqual \ 'function(''ale#references#HandleLSPResponse'')', \ string(g:Callback) diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader index 749f4d7e..7f0e3fcb 100644 --- a/test/test_go_to_definition.vader +++ b/test/test_go_to_definition.vader @@ -3,17 +3,17 @@ Before: call ale#test#SetFilename('dummy.txt') let g:old_filename = expand('%:p') - let g:Callback = 0 + let g:Callback = '' let g:message_list = [] let g:expr_list = [] + let g:capability_checked = '' + let g:WaitCallback = v:null runtime autoload/ale/linter.vim runtime autoload/ale/lsp.vim runtime autoload/ale/util.vim - function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort - let g:Callback = a:callback - + function! ale#lsp_linter#StartLSP(buffer, linter) abort let l:conn = ale#lsp#NewConnection({}) let l:conn.id = 347 let l:conn.open_documents = {a:buffer : -1} @@ -26,6 +26,15 @@ Before: \} endfunction + function! ale#lsp#WaitForCapability(conn_id, project_root, capability, callback) abort + let g:capability_checked = a:capability + let g:WaitCallback = a:callback + endfunction + + function! ale#lsp#RegisterCallback(conn_id, callback) abort + let g:Callback = a:callback + endfunction + function! ale#lsp#Send(conn_id, message, root) abort call add(g:message_list, a:message) @@ -42,6 +51,8 @@ After: call ale#test#RestoreDirectory() call ale#linter#Reset() + unlet! g:capability_checked + unlet! g:WaitCallback unlet! g:old_filename unlet! g:Callback unlet! g:message_list @@ -137,6 +148,13 @@ Execute(tsserver completion requests should be sent): ALEGoToDefinition + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual type(function('type')), type(g:WaitCallback) + AssertEqual 'definition', g:capability_checked + call call(g:WaitCallback, [347, '/foo/bar']) + AssertEqual \ 'function(''ale#definition#HandleTSServerResponse'')', \ string(g:Callback) @@ -151,6 +169,13 @@ Execute(tsserver tab completion requests should be sent): ALEGoToDefinitionInTab + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual type(function('type')), type(g:WaitCallback) + AssertEqual 'definition', g:capability_checked + call call(g:WaitCallback, [347, '/foo/bar']) + AssertEqual \ 'function(''ale#definition#HandleTSServerResponse'')', \ string(g:Callback) @@ -276,6 +301,13 @@ Execute(LSP completion requests should be sent): ALEGoToDefinition + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual type(function('type')), type(g:WaitCallback) + AssertEqual 'definition', g:capability_checked + call call(g:WaitCallback, [347, '/foo/bar']) + AssertEqual \ 'function(''ale#definition#HandleLSPResponse'')', \ string(g:Callback) @@ -305,6 +337,13 @@ Execute(LSP tab completion requests should be sent): ALEGoToDefinitionInTab + " We shouldn't register the callback yet. + AssertEqual '''''', string(g:Callback) + + AssertEqual type(function('type')), type(g:WaitCallback) + AssertEqual 'definition', g:capability_checked + call call(g:WaitCallback, [347, '/foo/bar']) + AssertEqual \ 'function(''ale#definition#HandleLSPResponse'')', \ string(g:Callback) diff --git a/test/test_lint_file_linters.vader b/test/test_lint_file_linters.vader index 14339e21..ca093aa8 100644 --- a/test/test_lint_file_linters.vader +++ b/test/test_lint_file_linters.vader @@ -51,7 +51,7 @@ Before: function! GetSimplerLoclist() let l:loclist = [] - for l:item in getloclist(0) + for l:item in ale#test#GetLoclistWithoutModule() call add(l:loclist, { \ 'lnum': l:item.lnum, \ 'col': l:item.col, diff --git a/test/test_lint_on_enter_when_file_changed.vader b/test/test_lint_on_enter_when_file_changed.vader index 8a54d9b8..67f43c17 100644 --- a/test/test_lint_on_enter_when_file_changed.vader +++ b/test/test_lint_on_enter_when_file_changed.vader @@ -61,7 +61,7 @@ Execute(The file changed event function should lint the current buffer when it h \ 'nr': -1, \ 'pattern': '', \ 'valid': 1, - \ }], getloclist(0) + \ }], ale#test#GetLoclistWithoutModule() Execute(The buffer should be checked after entering it after the file has changed): let b:ale_file_changed = 1 @@ -79,4 +79,4 @@ Execute(The buffer should be checked after entering it after the file has change \ 'nr': -1, \ 'pattern': '', \ 'valid': 1, - \ }], getloclist(0) + \ }], ale#test#GetLoclistWithoutModule() diff --git a/test/test_list_formatting.vader b/test/test_list_formatting.vader index 0c52f10f..dcefac53 100644 --- a/test/test_list_formatting.vader +++ b/test/test_list_formatting.vader @@ -53,7 +53,7 @@ Execute(Formatting with codes should work for the loclist): \ 'text': 'nocode', \ }, \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() call remove(g:loclist, 0) call AddItem({'text': 'withcode', 'code': 'E123'}) @@ -73,7 +73,7 @@ Execute(Formatting with codes should work for the loclist): \ 'text': 'E123: withcode', \ }, \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() Execute(Formatting with codes should work for the quickfix list): let g:ale_set_loclist = 0 @@ -96,7 +96,7 @@ Execute(Formatting with codes should work for the quickfix list): \ 'text': 'nocode', \ }, \ ], - \ getqflist() + \ ale#test#GetQflistWithoutModule() call remove(g:loclist, 0) call AddItem({'text': 'withcode', 'code': 'E123'}) @@ -116,7 +116,7 @@ Execute(Formatting with codes should work for the quickfix list): \ 'text': 'E123: withcode', \ }, \ ], - \ getqflist() + \ ale#test#GetQflistWithoutModule() Execute(Formatting with the linter name should work for the loclist): let g:ale_loclist_msg_format = '(%linter%) %s' @@ -138,7 +138,7 @@ Execute(Formatting with the linter name should work for the loclist): \ 'text': '(some_linter) whatever', \ }, \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() Execute(Formatting with the linter name should work for the quickfix list): let g:ale_loclist_msg_format = '(%linter%) %s' @@ -162,7 +162,7 @@ Execute(Formatting with the linter name should work for the quickfix list): \ 'text': '(some_linter) whatever', \ }, \ ], - \ getqflist() + \ ale#test#GetQflistWithoutModule() Execute(The buffer loclist format option should take precedence): let g:ale_loclist_msg_format = '(%linter%) %s' @@ -185,4 +185,4 @@ Execute(The buffer loclist format option should take precedence): \ 'text': 'FOO whatever', \ }, \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() diff --git a/test/test_list_opening.vader b/test/test_list_opening.vader index a24e8de9..8f0b2fd5 100644 --- a/test/test_list_opening.vader +++ b/test/test_list_opening.vader @@ -120,7 +120,7 @@ Execute(The quickfix window should be vertical for the loclist with appropriate call ale#list#SetLists(bufnr('%'), g:loclist) - AssertEqual 1, GetQuickfixIsVertical(b:ale_list_window_size) + AssertEqual 1, GetQuickfixIsVertical(8) Execute(The quickfix window should be horizontal for the loclist with appropriate variables): let g:ale_open_list = 1 @@ -129,7 +129,7 @@ Execute(The quickfix window should be horizontal for the loclist with appropriat call ale#list#SetLists(bufnr('%'), g:loclist) - AssertEqual 0, GetQuickfixIsVertical(b:ale_list_window_size) + AssertEqual 0, GetQuickfixIsVertical(8) Execute(The quickfix window should stay open for just the loclist): let g:ale_open_list = 1 @@ -207,7 +207,7 @@ Execute(The quickfix window should be vertical for the quickfix with appropriate call ale#list#SetLists(bufnr('%'), g:loclist) - AssertEqual 1, GetQuickfixIsVertical(b:ale_list_window_size) + AssertEqual 1, GetQuickfixIsVertical(8) Execute(The quickfix window should be horizontal for the quickfix with appropriate variables): let g:ale_open_list = 1 @@ -216,7 +216,7 @@ Execute(The quickfix window should be horizontal for the quickfix with appropria call ale#list#SetLists(bufnr('%'), g:loclist) - AssertEqual 0, GetQuickfixIsVertical(b:ale_list_window_size) + AssertEqual 0, GetQuickfixIsVertical(8) Execute(The buffer ale_open_list option should be respected): let b:ale_open_list = 1 diff --git a/test/test_list_titles.vader b/test/test_list_titles.vader index d521906f..1f0b2308 100644 --- a/test/test_list_titles.vader +++ b/test/test_list_titles.vader @@ -38,7 +38,7 @@ Execute(The loclist titles should be set appropriately): \ 'nr': 0, \ 'type': 'E', \ 'pattern': '', - \}], getloclist(0) + \}], ale#test#GetLoclistWithoutModule() if !has('nvim') AssertEqual @@ -68,7 +68,7 @@ Execute(The quickfix titles should be set appropriately): \ 'nr': 0, \ 'type': 'E', \ 'pattern': '', - \}], getqflist() + \}], ale#test#GetQflistWithoutModule() if !has('nvim') AssertEqual diff --git a/test/test_no_linting_on_write_quit.vader b/test/test_no_linting_on_write_quit.vader index db05bd7d..12ef38ed 100644 --- a/test/test_no_linting_on_write_quit.vader +++ b/test/test_no_linting_on_write_quit.vader @@ -59,14 +59,14 @@ Execute(No linting should be done on :wq or :x): " First try just the SaveEvent, to be sure that we set errors in the test. call ale#events#SaveEvent(bufnr('')) - AssertEqual 1, len(getloclist(0)) + AssertEqual 1, len(ale#test#GetLoclistWithoutModule()) " Now try doing it again, but where we run the quit event first. call setloclist(0, []) call ale#events#QuitEvent(bufnr('')) call ale#events#SaveEvent(bufnr('')) - AssertEqual [], getloclist(0) + AssertEqual [], ale#test#GetLoclistWithoutModule() Execute(No linting should be for :w after :q fails): let g:ale_lint_on_save = 1 @@ -79,7 +79,7 @@ Execute(No linting should be for :w after :q fails): call ale#events#SaveEvent(bufnr('')) - AssertEqual 1, len(getloclist(0)) + AssertEqual 1, len(ale#test#GetLoclistWithoutModule()) Execute(No linting should be done on :wq or :x after fixing files): let g:ale_lint_on_save = 0 @@ -87,14 +87,14 @@ Execute(No linting should be done on :wq or :x after fixing files): call ale#events#SaveEvent(bufnr('')) - AssertEqual 1, len(getloclist(0)) + AssertEqual 1, len(ale#test#GetLoclistWithoutModule()) " Now try doing it again, but where we run the quit event first. call setloclist(0, []) call ale#events#QuitEvent(bufnr('')) call ale#events#SaveEvent(bufnr('')) - AssertEqual [], getloclist(0) + AssertEqual [], ale#test#GetLoclistWithoutModule() Execute(Linting should be done after :q fails and fixing files): let g:ale_lint_on_save = 0 @@ -107,4 +107,4 @@ Execute(Linting should be done after :q fails and fixing files): call ale#events#SaveEvent(bufnr('')) - AssertEqual 1, len(getloclist(0)) + AssertEqual 1, len(ale#test#GetLoclistWithoutModule()) diff --git a/test/test_results_not_cleared_when_opening_loclist.vader b/test/test_results_not_cleared_when_opening_loclist.vader index dd928fa0..4a53d356 100644 --- a/test/test_results_not_cleared_when_opening_loclist.vader +++ b/test/test_results_not_cleared_when_opening_loclist.vader @@ -27,4 +27,4 @@ Execute(The loclist shouldn't be cleared when opening the loclist): :lopen :q - AssertEqual 1, len(getloclist(0)), 'The loclist was cleared' + AssertEqual 1, len(ale#test#GetLoclistWithoutModule()), 'The loclist was cleared' diff --git a/test/test_set_list_timers.vader b/test/test_set_list_timers.vader index f8fcb6a0..e53b97a4 100644 --- a/test/test_set_list_timers.vader +++ b/test/test_set_list_timers.vader @@ -26,4 +26,4 @@ Execute(The SetLists function should work when run in a timer): \ 'nr': 0, \ 'type': 'E', \ 'pattern': '', - \}], getloclist(0) + \}], ale#test#GetLoclistWithoutModule() diff --git a/test/test_setting_loclist_from_another_buffer.vader b/test/test_setting_loclist_from_another_buffer.vader index 10a44cce..028ffb1e 100644 --- a/test/test_setting_loclist_from_another_buffer.vader +++ b/test/test_setting_loclist_from_another_buffer.vader @@ -21,6 +21,6 @@ Execute(Errors should be set in the loclist for the original buffer, not the new \ g:ale_buffer_info[(g:original_buffer)].loclist, \ ) - AssertEqual [], getloclist(0) + AssertEqual [], ale#test#GetLoclistWithoutModule() AssertEqual 1, len(getloclist(bufwinid(g:original_buffer))) AssertEqual 'foo', getloclist(bufwinid(g:original_buffer))[0].text diff --git a/test/test_setting_problems_found_in_previous_buffers.vader b/test/test_setting_problems_found_in_previous_buffers.vader index 45dfa662..4604005a 100644 --- a/test/test_setting_problems_found_in_previous_buffers.vader +++ b/test/test_setting_problems_found_in_previous_buffers.vader @@ -95,4 +95,4 @@ Execute(Problems found from previously opened buffers should be set when linting \ {'lnum': 2, 'bufnr': bufnr(''), 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'E', 'pattern': '', 'text': 'bar'}, \ {'lnum': 3, 'bufnr': bufnr(''), 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'E', 'pattern': '', 'text': 'baz'}, \ ], - \ getloclist(0) + \ ale#test#GetLoclistWithoutModule() |