All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 Save g:ale_run_synchronously
5 Save g:ale_set_highlights
7 Save g:ale_set_quickfix
9 Save g:ale_command_wrapper
11 let g:ale_command_wrapper = ''
12 let g:ale_buffer_info = {}
13 let g:ale_run_synchronously = 1
14 let g:ale_set_signs = 1
15 " Disable features we don't need for these tests.
16 let g:ale_set_quickfix = 0
17 let g:ale_set_loclist = 0
18 let g:ale_set_highlights = 0
19 let g:ale_echo_cursor = 0
21 call ale#linter#Reset()
24 function! GenerateResults(buffer, output)
48 \ 'text': 'use this one',
54 \ 'text': 'ignore this one',
60 \ 'text': 'ignore this one',
66 \ 'text': 'use this one',
71 function! ParseSigns()
73 if has('nvim-0.4.2') || has('patch-8.1.614')
74 silent sign place group=ale_signs
81 \ split(l:output, '\n')[2:],
82 \ 'matchlist(v:val, ''' . ale#sign#ParsePattern() . ''')[1:3]',
86 call ale#linter#Define('testft', {
88 \ 'executable': has('win32') ? 'cmd' : 'true',
90 \ 'callback': 'GenerateResults',
96 unlet! g:ale_run_synchronously_callbacks
98 delfunction GenerateResults
99 delfunction ParseSigns
100 call ale#linter#Reset()
101 call ale#sign#Clear()
103 Execute(ale#sign#GetSignName should return the right sign names):
104 AssertEqual 'ALEErrorSign', ale#sign#GetSignName([{'type': 'E'}])
105 AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([{'type': 'E', 'sub_type': 'style'}])
106 AssertEqual 'ALEWarningSign', ale#sign#GetSignName([{'type': 'W'}])
107 AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([{'type': 'W', 'sub_type': 'style'}])
108 AssertEqual 'ALEInfoSign', ale#sign#GetSignName([{'type': 'I'}])
109 AssertEqual 'ALEErrorSign', ale#sign#GetSignName([
113 \ {'type': 'E', 'sub_type': 'style'},
114 \ {'type': 'W', 'sub_type': 'style'},
116 AssertEqual 'ALEWarningSign', ale#sign#GetSignName([
119 \ {'type': 'E', 'sub_type': 'style'},
120 \ {'type': 'W', 'sub_type': 'style'},
122 AssertEqual 'ALEInfoSign', ale#sign#GetSignName([
124 \ {'type': 'E', 'sub_type': 'style'},
125 \ {'type': 'W', 'sub_type': 'style'},
127 AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([
128 \ {'type': 'E', 'sub_type': 'style'},
129 \ {'type': 'W', 'sub_type': 'style'},
131 AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([
132 \ {'type': 'W', 'sub_type': 'style'},
135 Given testft(A file with warnings/errors):
142 Execute(The current signs should be set for running a job):
144 call ale#test#FlushJobs()
148 \ ['1', '1000001', 'ALEErrorSign'],
149 \ ['2', '1000002', 'ALEWarningSign'],
150 \ ['3', '1000003', 'ALEErrorSign'],
151 \ ['4', '1000004', 'ALEErrorSign'],
152 \ ['5', '1000005', 'ALEErrorSign'],
156 Execute(Loclist items with sign_id values should be kept):
157 if has('nvim-0.4.2') || has('patch-8.1.614')
158 exec 'sign place 1000347 group=ale_signs line=3 name=ALEErrorSign buffer=' . bufnr('')
159 exec 'sign place 1000348 group=ale_signs line=15 name=ALEErrorSign buffer=' . bufnr('')
160 exec 'sign place 1000349 group=ale_signs line=16 name=ALEWarningSign buffer=' . bufnr('')
162 exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('')
163 exec 'sign place 1000348 line=15 name=ALEErrorSign buffer=' . bufnr('')
164 exec 'sign place 1000349 line=16 name=ALEWarningSign buffer=' . bufnr('')
168 \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
169 \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000349},
170 \ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
171 \ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
172 \ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
173 \ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
176 call ale#sign#SetSigns(bufnr(''), g:loclist)
178 " Sign IDs from before should be kept, and new signs should use
179 " IDs that haven't been used yet.
182 \ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
183 \ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000350},
184 \ {'bufnr': bufnr(''), 'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
185 \ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000348},
186 \ {'bufnr': bufnr(''), 'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000351},
187 \ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000351},
191 " Items should be grouped again. We should see error signs, where there
192 " were warnings before, and errors where there were errors and where we
193 " now have new warnings.
196 \ ['15', '1000348', 'ALEErrorSign'],
197 \ ['16', '1000351', 'ALEErrorSign'],
198 \ ['3', '1000347', 'ALEErrorSign'],
199 \ ['4', '1000350', 'ALEWarningSign'],
203 Execute(Items for other buffers should be ignored):
205 \ {'bufnr': bufnr('') - 1, 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
206 \ {'bufnr': bufnr('') - 1, 'lnum': 2, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000347},
207 \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
208 \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b'},
209 \ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c'},
210 \ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
211 \ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
212 \ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
213 \ {'bufnr': bufnr('') + 1, 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
216 call ale#sign#SetSigns(bufnr(''), g:loclist)
220 \ ['1', '1000001', 'ALEErrorSign'],
221 \ ['15', '1000005', 'ALEWarningSign'],
222 \ ['16', '1000006', 'ALEErrorSign'],
223 \ ['2', '1000002', 'ALEWarningSign'],
224 \ ['3', '1000003', 'ALEErrorSign'],
225 \ ['4', '1000004', 'ALEWarningSign'],
229 Execute(Signs should be downgraded correctly):
230 call ale#sign#SetSigns(bufnr(''), [
231 \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
232 \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
237 \ ['1', '1000001', 'ALEErrorSign'],
238 \ ['2', '1000002', 'ALEWarningSign'],
242 call ale#sign#SetSigns(bufnr(''), [
243 \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
244 \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
249 \ ['1', '1000003', 'ALEWarningSign'],
250 \ ['2', '1000004', 'ALEInfoSign'],
254 Execute(Signs should be upgraded correctly):
255 call ale#sign#SetSigns(bufnr(''), [
256 \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
257 \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
262 \ ['1', '1000001', 'ALEWarningSign'],
263 \ ['2', '1000002', 'ALEInfoSign'],
267 call ale#sign#SetSigns(bufnr(''), [
268 \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
269 \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
274 \ ['1', '1000003', 'ALEErrorSign'],
275 \ ['2', '1000004', 'ALEWarningSign'],
279 Execute(It should be possible to clear signs with empty lists):
280 " We can fail to remove signs if there are multiple signs on one line,
281 " say after deleting lines in Vim, etc.
282 if has('nvim-0.4.2') || has('patch-8.1.614')
283 exec 'sign place 1000347 group=ale_signs line=3 name=ALEErrorSign buffer=' . bufnr('')
284 exec 'sign place 1000348 group=ale_signs line=3 name=ALEWarningSign buffer=' . bufnr('')
285 exec 'sign place 1000349 group=ale_signs line=10 name=ALEErrorSign buffer=' . bufnr('')
286 exec 'sign place 1000350 group=ale_signs line=10 name=ALEWarningSign buffer=' . bufnr('')
288 exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('')
289 exec 'sign place 1000348 line=3 name=ALEWarningSign buffer=' . bufnr('')
290 exec 'sign place 1000349 line=10 name=ALEErrorSign buffer=' . bufnr('')
291 exec 'sign place 1000350 line=10 name=ALEWarningSign buffer=' . bufnr('')
294 call ale#sign#SetSigns(bufnr(''), [])
295 AssertEqual [], ParseSigns()
297 Execute(No exceptions should be thrown when setting signs for invalid buffers):
298 call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}])