This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/test/test_ale_lint_command.vader
2018-06-19 20:12:49 +01:00

65 lines
1.2 KiB
Text

Before:
Save g:ale_buffer_info
let g:ale_buffer_info = {}
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,
\ 'text': join(split(a:output[0])),
\ 'type': 'E',
\ 'nr': -1,
\}]
endfunction
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'ToggleTestCallback',
\ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo foo bar',
\})
After:
Restore
unlet! g:expected_loclist
let g:ale_buffer_info = {}
call ale#linter#Reset()
delfunction ToggleTestCallback
Given foobar (Some imaginary filetype):
foo
bar
baz
Execute(ALELint should run the linters):
AssertEqual 'foobar', &filetype
ALELint
call ale#engine#WaitForJobs(2000)
if !has('nvim')
" Sleep so the delayed list function can run.
" This breaks the tests in NeoVim for some reason.
sleep 1ms
endif
" Check the loclist
AssertEqual g:expected_loclist, getloclist(0)