diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fix/test_ale_fix.vader | 1 | ||||
-rw-r--r-- | test/test_alejobstarted_autocmd.vader | 11 | ||||
-rw-r--r-- | test/test_autocmd_commands.vader | 12 | ||||
-rw-r--r-- | test/test_checkingbuffer_autocmd.vader | 18 | ||||
-rw-r--r-- | test/test_lint_on_enter_when_file_changed.vader | 2 | ||||
-rw-r--r-- | test/test_lint_on_filetype_changed.vader | 35 | ||||
-rw-r--r-- | test/test_no_linting_on_write_quit.vader | 15 | ||||
-rw-r--r-- | test/test_pattern_options.vader | 22 | ||||
-rw-r--r-- | test/test_quitting_variable.vader | 4 |
9 files changed, 71 insertions, 49 deletions
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader index 417394c3..80eda4a0 100644 --- a/test/fix/test_ale_fix.vader +++ b/test/fix/test_ale_fix.vader @@ -31,6 +31,7 @@ Before: call ale#test#SetDirectory('/testplugin/test') call ale#test#SetFilename('test.txt') + call ale#linter#PreventLoading('testft') function AddCarets(buffer, lines) abort " map() is applied to the original lines here. diff --git a/test/test_alejobstarted_autocmd.vader b/test/test_alejobstarted_autocmd.vader index 51a57881..388e5439 100644 --- a/test/test_alejobstarted_autocmd.vader +++ b/test/test_alejobstarted_autocmd.vader @@ -1,6 +1,6 @@ -Given testft (An empty file): - Before: + Save g:ale_buffer_info + let g:job_started_success = 0 let g:ale_run_synchronously = 1 @@ -10,6 +10,7 @@ Before: return [] endfunction + call ale#linter#PreventLoading('testft') call ale#linter#Define('testft', { \ 'name': 'testlinter', \ 'callback': 'TestCallback', @@ -18,8 +19,9 @@ Before: \}) After: + Restore + let g:ale_run_synchronously = 0 - let g:ale_buffer_info = {} try augroup! VaderTest @@ -31,12 +33,13 @@ After: delfunction TestCallback call ale#linter#Reset() +Given testft (An empty file): Execute(Run a lint cycle with an actual job to check for ALEJobStarted): augroup VaderTest autocmd! autocmd User ALEJobStarted let g:job_started_success = 1 augroup end - call ale#Lint() + ALELint AssertEqual g:job_started_success, 1 diff --git a/test/test_autocmd_commands.vader b/test/test_autocmd_commands.vader index 5b48be99..8d5048f0 100644 --- a/test/test_autocmd_commands.vader +++ b/test/test_autocmd_commands.vader @@ -79,11 +79,9 @@ Execute (All events should be set up when everything is on): AssertEqual \ [ - \ 'BufEnter * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))', - \ 'BufEnter call ale#events#EnterEvent(str2nr(expand(''<abuf>'')))', - \ 'BufReadPost * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))', - \ 'BufReadPost call ale#Queue(0, ''lint_file'', str2nr(expand(''<abuf>'')))', - \ 'BufWinEnter * call ale#Queue(0, ''lint_file'', str2nr(expand(''<abuf>'')))', + \ 'BufEnter * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))', + \ 'BufReadPost * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))', + \ 'BufWinEnter * call ale#events#LintOnEnter(str2nr(expand(''<abuf>'')))', \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))', \ 'CursorHold * if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarningWithDelay() | endif', \ 'CursorMoved * if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarningWithDelay() | endif', @@ -110,8 +108,8 @@ Execute (Only the required events should be bound even if various settings are o AssertEqual \ [ - \ 'BufEnter * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))', - \ 'BufReadPost * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))', + \ 'BufEnter * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))', + \ 'BufReadPost * call ale#events#ReadOrEnterEvent(str2nr(expand(''<abuf>'')))', \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))', \ ], \ CheckAutocmd('ALEEvents') diff --git a/test/test_checkingbuffer_autocmd.vader b/test/test_checkingbuffer_autocmd.vader index 1cbfa342..9e3a8188 100644 --- a/test/test_checkingbuffer_autocmd.vader +++ b/test/test_checkingbuffer_autocmd.vader @@ -1,9 +1,7 @@ -Given testft (An empty file): - Before: Save g:ale_run_synchronously Save g:ale_buffer_info - + let g:ale_run_synchronously = 1 let g:ale_buffer_info = {} @@ -15,6 +13,7 @@ Before: return [] endfunction + call ale#linter#PreventLoading('testft') call ale#linter#Define('testft', { \ 'name': 'testlinter', \ 'callback': 'TestCallback', @@ -26,32 +25,33 @@ After: Restore unlet! g:checking_buffer - + delfunction TestCallback call ale#linter#Reset() - + augroup VaderTest autocmd! augroup end augroup! VaderTest +Given testft (An empty file): Execute(ALELintPre should not return success on ale#engine#IsCheckingBuffer): augroup VaderTest autocmd! - autocmd User ALELintPre let g:checking_buffer = ale#engine#IsCheckingBuffer(bufnr('')) ? 1 : 0 + autocmd User ALELintPre let g:checking_buffer = ale#engine#IsCheckingBuffer(bufnr('')) ? 1 : 0 augroup end - call ale#Lint() + ALELint AssertEqual g:checking_buffer, 0 Execute(ALEJobStarted should return success on ale#engine#IsCheckingBuffer): augroup VaderTest autocmd! - autocmd User ALEJobStarted let g:checking_buffer = ale#engine#IsCheckingBuffer(bufnr('')) ? 1 : 0 + autocmd User ALEJobStarted let g:checking_buffer = ale#engine#IsCheckingBuffer(bufnr('')) ? 1 : 0 augroup end - call ale#Lint() + ALELint AssertEqual g:checking_buffer, 1 diff --git a/test/test_lint_on_enter_when_file_changed.vader b/test/test_lint_on_enter_when_file_changed.vader index d2b38e04..8a54d9b8 100644 --- a/test/test_lint_on_enter_when_file_changed.vader +++ b/test/test_lint_on_enter_when_file_changed.vader @@ -67,7 +67,7 @@ Execute(The buffer should be checked after entering it after the file has change let b:ale_file_changed = 1 set filetype=foobar - call ale#events#EnterEvent(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual [{ \ 'bufnr': bufnr(''), diff --git a/test/test_lint_on_filetype_changed.vader b/test/test_lint_on_filetype_changed.vader index 591a5120..cfc99d58 100644 --- a/test/test_lint_on_filetype_changed.vader +++ b/test/test_lint_on_filetype_changed.vader @@ -1,10 +1,10 @@ Before: Save &filetype + Save g:ale_lint_on_filetype_changed + let g:ale_lint_on_filetype_changed = 1 let g:queue_calls = [] - unlet! b:ale_lint_on_enter - function! ale#Queue(...) call add(g:queue_calls, a:000) endfunction @@ -12,7 +12,6 @@ Before: After: Restore - unlet! b:ale_lint_on_enter unlet! g:queue_calls " Reload the ALE code to load the real function again. @@ -23,13 +22,13 @@ After: Execute(The original filetype should be set on BufEnter): let &filetype = 'foobar' - call ale#events#EnterEvent(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 'foobar', b:ale_original_filetype let &filetype = 'bazboz' - call ale#events#EnterEvent(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 'bazboz', b:ale_original_filetype @@ -48,27 +47,31 @@ Execute(Linting should be queued when the filetype changes): call ale#events#FileTypeEvent(bufnr(''), 'bazboz') AssertEqual [[300, 'lint_file', bufnr('')]], g:queue_calls + " The original filetype should be updated, so we don't trigger linting + " by setting a filetype equal to what it already is. + AssertEqual 'bazboz', b:ale_original_filetype -Execute(Linting shouldn't be done when the original filetype was blank and linting on enter is off): - let b:ale_lint_on_enter = 0 +Execute(Linting should be done when the original filetype was blank): let b:ale_original_filetype = '' call ale#events#FileTypeEvent(bufnr(''), 'bazboz') - AssertEqual [], g:queue_calls + AssertEqual [[300, 'lint_file', bufnr('')]], g:queue_calls + AssertEqual 'bazboz', b:ale_original_filetype -Execute(Linting should be done when the original filetype was blank and linting on enter is on): - let b:ale_lint_on_enter = 1 - let b:ale_original_filetype = '' +Execute(Linting should not be done when the setting is off): + let b:ale_original_filetype = 'foobar' + let g:ale_lint_on_filetype_changed = 0 call ale#events#FileTypeEvent(bufnr(''), 'bazboz') - AssertEqual [[300, 'lint_file', bufnr('')]], g:queue_calls + AssertEqual [], g:queue_calls + " We should still update the old filetype + AssertEqual 'bazboz', b:ale_original_filetype -Execute(The new filetype should become the "original" one if the original was blank and linting on enter is off): - let b:ale_lint_on_enter = 0 - let b:ale_original_filetype = '' +Execute(Linting should be done when the original filetype was not set): + unlet! b:ale_original_filetype call ale#events#FileTypeEvent(bufnr(''), 'bazboz') - AssertEqual 'bazboz', b:ale_original_filetype + AssertEqual [], g:queue_calls diff --git a/test/test_no_linting_on_write_quit.vader b/test/test_no_linting_on_write_quit.vader index d3baeaa1..db05bd7d 100644 --- a/test/test_no_linting_on_write_quit.vader +++ b/test/test_no_linting_on_write_quit.vader @@ -3,9 +3,21 @@ Before: Save g:ale_fix_on_save Save g:ale_fixers Save g:ale_lint_on_save + Save g:ale_set_highlights + Save g:ale_set_lists_synchronously + Save g:ale_set_loclist + Save g:ale_set_quickfix + Save g:ale_set_signs - let g:ale_echo_cursor = 0 let g:ale_run_synchronously = 1 + let g:ale_set_lists_synchronously = 1 + " Disable the things we don't need, but leave enabled what we do. + let g:ale_echo_cursor = 0 + let g:ale_set_signs = 0 + let g:ale_set_quickfix = 0 + let g:ale_set_loclist = 1 + let g:ale_set_highlights = 0 + let g:ale_echo_cursor = 0 function! TestCallback(buffer, output) return [{'lnum': 1, 'col': 1, 'text': 'xxx'}] @@ -19,6 +31,7 @@ Before: \ 'testft': ['AddLine'], \} + call ale#linter#PreventLoading('testft') call ale#linter#Define('testft', { \ 'name': 'testlinter', \ 'callback': 'TestCallback', diff --git a/test/test_pattern_options.vader b/test/test_pattern_options.vader index f439afbd..3b6500e5 100644 --- a/test/test_pattern_options.vader +++ b/test/test_pattern_options.vader @@ -1,8 +1,12 @@ Before: Save g:ale_pattern_options Save g:ale_pattern_options_enabled + Save b:ale_quitting + Save b:ale_original_filetype Save &filetype + unlet! b:ale_file_changed + let g:ale_pattern_options_enabled = 1 let g:ale_pattern_options = {} @@ -21,7 +25,7 @@ After: Execute(The pattern options function should work when there are no patterns): call ale#test#SetFilename('foobar.js') - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) Execute(Buffer variables should be set when filename patterns match): let g:ale_pattern_options = { @@ -33,13 +37,13 @@ Execute(Buffer variables should be set when filename patterns match): \} call ale#test#SetFilename('foobar.js') - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 0, b:ale_enabled AssertEqual 0, b:some_option call ale#test#SetFilename('bazboz.js') - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 1, b:ale_enabled AssertEqual 347, b:some_option @@ -61,7 +65,7 @@ Execute(Multiple pattern matches should be applied): \} call ale#test#SetFilename('foobar.js') - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 1, b:ale_enabled AssertEqual 666, b:some_option @@ -71,7 +75,7 @@ Execute(Patterns should not be applied when the setting is disabled): let g:ale_pattern_options = {'foo': {'some_option': 666}} call ale#test#SetFilename('foobar.js') - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 0, b:some_option @@ -81,13 +85,13 @@ Execute(Patterns should be applied after the Dictionary changes): let g:ale_pattern_options = {} - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 0, b:some_option let g:ale_pattern_options['foo'] = {'some_option': 666} - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 666, b:some_option @@ -96,8 +100,8 @@ Execute(SetOptions should tolerate settings being unset): unlet! g:ale_pattern_options unlet! g:ale_pattern_options_enabled - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) let g:ale_pattern_options_enabled = 1 - call ale#pattern_options#SetOptions(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) diff --git a/test/test_quitting_variable.vader b/test/test_quitting_variable.vader index 38b43bb4..32eb0c36 100644 --- a/test/test_quitting_variable.vader +++ b/test/test_quitting_variable.vader @@ -18,10 +18,10 @@ Execute(QuitEvent should set b:ale_quitting some time from the clock): Assert b:ale_quitting >= b:time_before Assert b:ale_quitting <= ale#events#ClockMilliseconds() -Execute(EnterEvent should set b:ale_quitting to 0): +Execute(ReadOrEnterEvent should set b:ale_quitting to 0): let b:ale_quitting = 1 - call ale#events#EnterEvent(bufnr('')) + call ale#events#ReadOrEnterEvent(bufnr('')) AssertEqual 0, b:ale_quitting |