2017-06-24 07:24:31 -04:00
|
|
|
Before:
|
|
|
|
Save &filetype
|
|
|
|
Save g:ale_buffer_info
|
|
|
|
Save g:ale_lint_on_enter
|
2017-10-22 20:26:31 -04:00
|
|
|
Save g:ale_set_lists_synchronously
|
|
|
|
|
2017-06-24 07:24:31 -04:00
|
|
|
let g:buf = bufnr('')
|
|
|
|
let g:ale_lint_on_enter = 1
|
|
|
|
let g:ale_run_synchronously = 1
|
2017-10-22 20:26:31 -04:00
|
|
|
let g:ale_set_lists_synchronously = 1
|
2017-06-24 07:24:31 -04:00
|
|
|
|
|
|
|
function! TestCallback(buffer, output)
|
|
|
|
return [{
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'baz boz',
|
|
|
|
\}]
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'TestCallback',
|
2017-10-22 20:26:31 -04:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'true',
|
|
|
|
\ 'command': has('win32') ? 'echo' : 'true',
|
2017-06-24 07:24:31 -04:00
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
|
|
|
Restore
|
|
|
|
unlet! g:buf
|
|
|
|
let g:ale_run_synchronously = 0
|
|
|
|
delfunction TestCallback
|
|
|
|
call ale#linter#Reset()
|
|
|
|
call setloclist(0, [])
|
|
|
|
|
|
|
|
Execute(The file changed event function should set b:ale_file_changed):
|
2017-07-07 18:47:41 -04:00
|
|
|
let g:ale_lint_on_enter = 0
|
|
|
|
|
2017-06-24 07:24:31 -04:00
|
|
|
if has('gui')
|
|
|
|
new
|
|
|
|
else
|
|
|
|
e test
|
|
|
|
endif
|
|
|
|
|
|
|
|
call ale#events#FileChangedEvent(g:buf)
|
|
|
|
close
|
|
|
|
|
|
|
|
" We should set the flag in the other buffer
|
|
|
|
AssertEqual 1, getbufvar(g:buf, 'ale_file_changed')
|
|
|
|
|
|
|
|
Execute(The file changed event function should lint the current buffer when it has changed):
|
|
|
|
set filetype=foobar
|
|
|
|
call ale#events#FileChangedEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-06-24 07:24:31 -04:00
|
|
|
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'bufnr': bufnr(''),
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'baz boz',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
2018-07-23 15:41:06 -04:00
|
|
|
\ }], ale#test#GetLoclistWithoutModule()
|
2017-06-24 07:24:31 -04:00
|
|
|
|
|
|
|
Execute(The buffer should be checked after entering it after the file has changed):
|
|
|
|
let b:ale_file_changed = 1
|
|
|
|
|
|
|
|
set filetype=foobar
|
2018-07-16 19:18:20 -04:00
|
|
|
call ale#events#ReadOrEnterEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-06-24 07:24:31 -04:00
|
|
|
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'bufnr': bufnr(''),
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'baz boz',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
2018-07-23 15:41:06 -04:00
|
|
|
\ }], ale#test#GetLoclistWithoutModule()
|