2017-02-11 18:14:18 +00:00
|
|
|
Before:
|
2018-07-16 13:03:08 +00:00
|
|
|
Save g:ale_buffer_info
|
|
|
|
Save g:ale_echo_cursor
|
|
|
|
Save g:ale_enabled
|
|
|
|
Save g:ale_run_synchronously
|
|
|
|
Save g:ale_set_highlights
|
|
|
|
Save g:ale_set_loclist
|
|
|
|
Save g:ale_set_quickfix
|
|
|
|
Save g:ale_set_signs
|
|
|
|
|
|
|
|
" Disable the features we don't need to check.
|
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
let g:ale_echo_cursor = 0
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
let g:ale_run_synchronously = 1
|
2019-02-06 22:00:11 +00:00
|
|
|
unlet! g:ale_run_synchronously_callbacks
|
2018-07-16 13:03:08 +00:00
|
|
|
let g:ale_set_highlights = 0
|
|
|
|
let g:ale_set_loclist = 0
|
|
|
|
let g:ale_set_quickfix = 0
|
|
|
|
let g:ale_set_signs = 0
|
|
|
|
|
2017-02-11 18:14:18 +00:00
|
|
|
let g:output = []
|
|
|
|
|
|
|
|
function! TestCallback(buffer, output)
|
2018-07-16 13:18:50 +00:00
|
|
|
" Extract just letters from the output.
|
|
|
|
let g:output = filter(
|
|
|
|
\ map(a:output, 'matchstr(v:val, ''[a-zA-Z]\+'')'),
|
|
|
|
\ '!empty(v:val)'
|
|
|
|
\)
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
return []
|
|
|
|
endfunction
|
|
|
|
|
2018-07-16 13:03:08 +00:00
|
|
|
call ale#linter#PreventLoading('foobar')
|
2017-02-11 18:14:18 +00:00
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'TestCallback',
|
2017-10-23 00:26:31 +00:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'cat',
|
|
|
|
\ 'command': has('win32') ? 'type %t' : 'cat %t',
|
2017-02-11 18:14:18 +00:00
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
2018-07-16 13:03:08 +00:00
|
|
|
Restore
|
|
|
|
|
2019-02-06 22:00:11 +00:00
|
|
|
unlet! g:ale_run_synchronously_callbacks
|
2017-02-11 18:14:18 +00:00
|
|
|
unlet! g:output
|
|
|
|
delfunction TestCallback
|
2018-06-28 12:53:49 +00:00
|
|
|
|
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
2017-02-11 18:14:18 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
Given foobar (Some imaginary filetype):
|
|
|
|
foo
|
|
|
|
bar
|
|
|
|
baz
|
|
|
|
|
|
|
|
Execute(ALE should be able to read the %t file):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
2018-07-16 13:03:08 +00:00
|
|
|
ALELint
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
AssertEqual ['foo', 'bar', 'baz'], g:output
|