2017-02-04 13:30:30 -05:00
|
|
|
Before:
|
2017-05-12 16:16:15 -04:00
|
|
|
Save &shell, g:ale_run_synchronously
|
|
|
|
let g:ale_run_synchronously = 1
|
2017-10-23 18:09:40 -04:00
|
|
|
|
|
|
|
if !has('win32')
|
|
|
|
set shell=/bin/sh
|
|
|
|
endif
|
|
|
|
|
2017-02-04 13:30:30 -05:00
|
|
|
let g:linter_output = []
|
|
|
|
let g:first_echo_called = 0
|
|
|
|
let g:second_echo_called = 0
|
|
|
|
let g:final_callback_called = 0
|
|
|
|
|
|
|
|
function! CollectResults(buffer, output)
|
|
|
|
let g:final_callback_called = 1
|
2017-10-23 18:09:40 -04:00
|
|
|
let g:linter_output = map(copy(a:output), 'join(split(v:val))')
|
2017-02-04 13:30:30 -05:00
|
|
|
return []
|
|
|
|
endfunction
|
|
|
|
function! RunFirstEcho(buffer)
|
|
|
|
let g:first_echo_called = 1
|
|
|
|
|
|
|
|
return 'echo foo'
|
|
|
|
endfunction
|
|
|
|
function! RunSecondEcho(buffer, output)
|
|
|
|
let g:second_echo_called = 1
|
|
|
|
|
|
|
|
return 'echo bar'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'CollectResults',
|
2017-10-23 18:09:40 -04:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
2017-02-04 13:30:30 -05:00
|
|
|
\ 'command_chain': [
|
|
|
|
\ {
|
|
|
|
\ 'callback': 'RunFirstEcho',
|
|
|
|
\ 'output_stream': 'stdout',
|
2017-03-25 21:13:21 -04:00
|
|
|
\ 'read_buffer': 0,
|
2017-02-04 13:30:30 -05:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'callback': 'RunSecondEcho',
|
|
|
|
\ 'output_stream': 'stdout',
|
2017-03-25 21:13:21 -04:00
|
|
|
\ 'read_buffer': 0,
|
2017-02-04 13:30:30 -05:00
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
2017-05-12 16:16:15 -04:00
|
|
|
Restore
|
2017-02-04 13:30:30 -05:00
|
|
|
unlet! g:first_echo_called
|
|
|
|
unlet! g:second_echo_called
|
|
|
|
unlet! g:final_callback_called
|
|
|
|
unlet! g:linter_output
|
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
call ale#linter#Reset()
|
|
|
|
delfunction CollectResults
|
|
|
|
delfunction RunFirstEcho
|
|
|
|
delfunction RunSecondEcho
|
|
|
|
|
|
|
|
Given foobar (Some imaginary filetype):
|
|
|
|
anything
|
|
|
|
|
|
|
|
Execute(Check the results of running the chain):
|
|
|
|
AssertEqual 'foobar', &filetype
|
2018-10-29 07:29:12 -04:00
|
|
|
call ale#Queue(0)
|
2017-02-04 13:30:30 -05:00
|
|
|
|
|
|
|
Assert g:first_echo_called, 'The first chain item was not called'
|
|
|
|
Assert g:second_echo_called, 'The second chain item was not called'
|
|
|
|
Assert g:final_callback_called, 'The final callback was not called'
|
|
|
|
AssertEqual ['bar'], g:linter_output
|