1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
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
unlet! b:i
call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset()
let g:ale_buffer_info = {}
delfunction ToggleTestCallback
Given foobar (Some imaginary filetype):
foo
bar
baz
Execute(ALELint should run the linters):
AssertEqual 'foobar', &filetype
" 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)
if !has('nvim')
" Sleep so the delayed list function can run.
" This breaks the tests in NeoVim for some reason.
sleep 1ms
endif
if getloclist(0) == g:expected_loclist
break
endif
endfor
" Check the loclist
AssertEqual g:expected_loclist, getloclist(0)
|