2017-02-28 04:10:58 -05:00
|
|
|
Before:
|
2017-08-13 17:27:01 -04:00
|
|
|
Save g:ale_buffer_info
|
|
|
|
|
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
|
2017-02-28 04:10:58 -05:00
|
|
|
let g:expected_loclist = [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'foo bar',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
|
|
|
\}]
|
|
|
|
|
|
|
|
function! ToggleTestCallback(buffer, output)
|
|
|
|
return [{
|
|
|
|
\ 'bufnr': a:buffer,
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
2017-10-23 18:09:40 -04:00
|
|
|
\ 'text': join(split(a:output[0])),
|
2017-02-28 04:10:58 -05:00
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\}]
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'ToggleTestCallback',
|
2017-10-23 18:09:40 -04:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
2017-02-28 04:10:58 -05:00
|
|
|
\ 'command': 'echo foo bar',
|
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
2017-08-13 17:27:01 -04:00
|
|
|
Restore
|
|
|
|
|
2017-02-28 04:10:58 -05:00
|
|
|
unlet! g:expected_loclist
|
2018-07-15 13:24:53 -04:00
|
|
|
unlet! b:i
|
2017-02-28 04:10:58 -05:00
|
|
|
|
2018-06-28 08:53:49 -04:00
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
2017-02-28 04:10:58 -05:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
2018-06-28 08:53:49 -04:00
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
|
2017-02-28 04:10:58 -05:00
|
|
|
delfunction ToggleTestCallback
|
|
|
|
|
|
|
|
Given foobar (Some imaginary filetype):
|
|
|
|
foo
|
|
|
|
bar
|
|
|
|
baz
|
|
|
|
|
|
|
|
Execute(ALELint should run the linters):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
2018-07-15 13:24:53 -04:00
|
|
|
" Try to run the linter a few times, as it fails randomly in NeoVim.
|
|
|
|
for b:i in range(5)
|
|
|
|
ALELint
|
|
|
|
call ale#engine#WaitForJobs(2000)
|
2017-02-28 04:10:58 -05:00
|
|
|
|
2018-07-15 13:24:53 -04:00
|
|
|
if !has('nvim')
|
|
|
|
" Sleep so the delayed list function can run.
|
|
|
|
" This breaks the tests in NeoVim for some reason.
|
|
|
|
sleep 1ms
|
|
|
|
endif
|
|
|
|
|
2018-07-23 15:41:06 -04:00
|
|
|
if ale#test#GetLoclistWithoutModule() == g:expected_loclist
|
2018-07-15 13:24:53 -04:00
|
|
|
break
|
|
|
|
endif
|
|
|
|
endfor
|
2017-10-23 18:09:40 -04:00
|
|
|
|
2017-02-28 04:10:58 -05:00
|
|
|
" Check the loclist
|
2018-07-23 15:41:06 -04:00
|
|
|
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|