2017-02-07 22:55:23 +00:00
|
|
|
Before:
|
2018-05-28 16:38:14 +00:00
|
|
|
Save g:ale_buffer_info
|
2018-06-28 12:53:49 +00:00
|
|
|
Save g:ale_echo_cursor
|
|
|
|
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
|
2020-08-16 20:19:07 +00:00
|
|
|
Save g:ale_command_wrapper
|
2017-08-26 15:38:27 +00:00
|
|
|
|
2020-08-16 20:19:07 +00:00
|
|
|
let g:ale_command_wrapper = ''
|
2018-05-28 16:38:14 +00:00
|
|
|
let g:ale_buffer_info = {}
|
2018-06-28 12:53:49 +00:00
|
|
|
let g:ale_run_synchronously = 1
|
|
|
|
let g:ale_set_signs = 1
|
|
|
|
" Disable features we don't need for these tests.
|
|
|
|
let g:ale_set_quickfix = 0
|
|
|
|
let g:ale_set_loclist = 0
|
|
|
|
let g:ale_set_highlights = 0
|
|
|
|
let g:ale_echo_cursor = 0
|
2017-08-26 15:38:27 +00:00
|
|
|
|
2017-09-02 15:57:01 +00:00
|
|
|
call ale#linter#Reset()
|
2019-09-25 08:15:16 +00:00
|
|
|
call ale#sign#Clear()
|
2017-09-02 15:57:01 +00:00
|
|
|
|
2017-02-07 22:55:23 +00:00
|
|
|
function! GenerateResults(buffer, output)
|
|
|
|
return [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'foo',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'bar',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 3,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'baz',
|
|
|
|
\ },
|
2017-03-11 17:39:51 +00:00
|
|
|
\ {
|
|
|
|
\ 'lnum': 4,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'use this one',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 4,
|
|
|
|
\ 'col': 2,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'ignore this one',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 5,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'ignore this one',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 5,
|
|
|
|
\ 'col': 2,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'use this one',
|
|
|
|
\ },
|
2017-02-07 22:55:23 +00:00
|
|
|
\]
|
|
|
|
endfunction
|
|
|
|
|
2017-03-14 23:04:25 +00:00
|
|
|
function! ParseSigns()
|
|
|
|
redir => l:output
|
2020-03-15 06:58:38 +00:00
|
|
|
if has('nvim-0.4.2') || has('patch-8.1.614')
|
2024-01-14 11:29:10 +00:00
|
|
|
silent sign place group=ale_signs
|
2019-09-25 08:15:16 +00:00
|
|
|
else
|
|
|
|
silent sign place
|
|
|
|
endif
|
2017-03-14 23:04:25 +00:00
|
|
|
redir END
|
|
|
|
|
|
|
|
return map(
|
|
|
|
\ split(l:output, '\n')[2:],
|
2019-09-25 08:15:16 +00:00
|
|
|
\ 'matchlist(v:val, ''' . ale#sign#ParsePattern() . ''')[1:3]',
|
2017-03-14 23:04:25 +00:00
|
|
|
\)
|
|
|
|
endfunction
|
|
|
|
|
2017-02-07 22:55:23 +00:00
|
|
|
call ale#linter#Define('testft', {
|
|
|
|
\ 'name': 'x',
|
2017-09-09 17:03:34 +00:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'true',
|
2017-05-05 09:36:23 +00:00
|
|
|
\ 'command': 'true',
|
2017-02-07 22:55:23 +00:00
|
|
|
\ 'callback': 'GenerateResults',
|
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
2017-08-26 15:38:27 +00:00
|
|
|
Restore
|
|
|
|
|
2019-04-07 13:58:06 +00:00
|
|
|
unlet! g:ale_run_synchronously_callbacks
|
2017-03-14 23:04:25 +00:00
|
|
|
unlet! g:loclist
|
2017-02-07 22:55:23 +00:00
|
|
|
delfunction GenerateResults
|
2017-03-14 23:04:25 +00:00
|
|
|
delfunction ParseSigns
|
|
|
|
call ale#linter#Reset()
|
2019-09-25 08:15:16 +00:00
|
|
|
call ale#sign#Clear()
|
2017-02-07 22:55:23 +00:00
|
|
|
|
2017-08-26 15:38:27 +00:00
|
|
|
Execute(ale#sign#GetSignName should return the right sign names):
|
|
|
|
AssertEqual 'ALEErrorSign', ale#sign#GetSignName([{'type': 'E'}])
|
|
|
|
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([{'type': 'E', 'sub_type': 'style'}])
|
|
|
|
AssertEqual 'ALEWarningSign', ale#sign#GetSignName([{'type': 'W'}])
|
|
|
|
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([{'type': 'W', 'sub_type': 'style'}])
|
|
|
|
AssertEqual 'ALEInfoSign', ale#sign#GetSignName([{'type': 'I'}])
|
|
|
|
AssertEqual 'ALEErrorSign', ale#sign#GetSignName([
|
2017-05-20 22:32:41 +00:00
|
|
|
\ {'type': 'E'},
|
|
|
|
\ {'type': 'W'},
|
|
|
|
\ {'type': 'I'},
|
|
|
|
\ {'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'type': 'W', 'sub_type': 'style'},
|
|
|
|
\])
|
2017-08-26 15:38:27 +00:00
|
|
|
AssertEqual 'ALEWarningSign', ale#sign#GetSignName([
|
2017-05-20 22:32:41 +00:00
|
|
|
\ {'type': 'W'},
|
|
|
|
\ {'type': 'I'},
|
|
|
|
\ {'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'type': 'W', 'sub_type': 'style'},
|
|
|
|
\])
|
2017-08-26 15:38:27 +00:00
|
|
|
AssertEqual 'ALEInfoSign', ale#sign#GetSignName([
|
2017-05-20 22:32:41 +00:00
|
|
|
\ {'type': 'I'},
|
|
|
|
\ {'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'type': 'W', 'sub_type': 'style'},
|
|
|
|
\])
|
2017-08-26 15:38:27 +00:00
|
|
|
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([
|
2017-05-20 22:32:41 +00:00
|
|
|
\ {'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'type': 'W', 'sub_type': 'style'},
|
|
|
|
\])
|
2017-08-26 15:38:27 +00:00
|
|
|
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([
|
2017-05-20 22:32:41 +00:00
|
|
|
\ {'type': 'W', 'sub_type': 'style'},
|
|
|
|
\])
|
|
|
|
|
2017-03-09 22:45:22 +00:00
|
|
|
Given testft(A file with warnings/errors):
|
2023-09-16 21:22:01 +00:00
|
|
|
Foo
|
|
|
|
Bar
|
|
|
|
Baz
|
|
|
|
Fourth line
|
|
|
|
Fifth line
|
2017-02-07 22:55:23 +00:00
|
|
|
|
2017-03-14 23:04:25 +00:00
|
|
|
Execute(The current signs should be set for running a job):
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-02-07 22:55:23 +00:00
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['1', '1000001', 'ALEErrorSign'],
|
|
|
|
\ ['2', '1000002', 'ALEWarningSign'],
|
|
|
|
\ ['3', '1000003', 'ALEErrorSign'],
|
2017-03-11 17:39:51 +00:00
|
|
|
\ ['4', '1000004', 'ALEErrorSign'],
|
|
|
|
\ ['5', '1000005', 'ALEErrorSign'],
|
2017-02-07 22:55:23 +00:00
|
|
|
\ ],
|
2017-03-14 23:04:25 +00:00
|
|
|
\ ParseSigns()
|
|
|
|
|
|
|
|
Execute(Loclist items with sign_id values should be kept):
|
2020-03-15 06:58:38 +00:00
|
|
|
if has('nvim-0.4.2') || has('patch-8.1.614')
|
2024-01-14 11:29:10 +00:00
|
|
|
exec 'sign place 1000347 group=ale_signs line=3 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000348 group=ale_signs line=15 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000349 group=ale_signs line=16 name=ALEWarningSign buffer=' . bufnr('')
|
2019-09-25 08:15:16 +00:00
|
|
|
else
|
|
|
|
exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000348 line=15 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000349 line=16 name=ALEWarningSign buffer=' . bufnr('')
|
|
|
|
endif
|
2017-03-14 23:04:25 +00:00
|
|
|
|
|
|
|
let g:loclist = [
|
2017-08-12 13:45:22 +00:00
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000349},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
2017-03-14 23:04:25 +00:00
|
|
|
\]
|
|
|
|
|
2017-08-26 15:38:27 +00:00
|
|
|
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
2017-03-14 23:04:25 +00:00
|
|
|
|
2017-06-07 22:12:45 +00:00
|
|
|
" Sign IDs from before should be kept, and new signs should use
|
|
|
|
" IDs that haven't been used yet.
|
2017-03-14 23:04:25 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
2017-08-12 13:45:22 +00:00
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000350},
|
2017-08-26 15:38:27 +00:00
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000348},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000351},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000351},
|
2017-03-14 23:04:25 +00:00
|
|
|
\ ],
|
|
|
|
\ g:loclist
|
|
|
|
|
|
|
|
" Items should be grouped again. We should see error signs, where there
|
|
|
|
" were warnings before, and errors where there were errors and where we
|
|
|
|
" now have new warnings.
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
2017-06-07 22:12:45 +00:00
|
|
|
\ ['15', '1000348', 'ALEErrorSign'],
|
2017-08-26 15:38:27 +00:00
|
|
|
\ ['16', '1000351', 'ALEErrorSign'],
|
2017-06-07 22:12:45 +00:00
|
|
|
\ ['3', '1000347', 'ALEErrorSign'],
|
|
|
|
\ ['4', '1000350', 'ALEWarningSign'],
|
2017-03-14 23:04:25 +00:00
|
|
|
\ ],
|
2017-06-07 22:12:45 +00:00
|
|
|
\ sort(ParseSigns())
|
2017-04-26 22:31:43 +00:00
|
|
|
|
2017-08-13 15:30:46 +00:00
|
|
|
Execute(Items for other buffers should be ignored):
|
|
|
|
let g:loclist = [
|
|
|
|
\ {'bufnr': bufnr('') - 1, 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
|
|
|
|
\ {'bufnr': bufnr('') - 1, 'lnum': 2, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000347},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
|
|
|
\ {'bufnr': bufnr('') + 1, 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
|
|
|
|
\]
|
|
|
|
|
|
|
|
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['1', '1000001', 'ALEErrorSign'],
|
|
|
|
\ ['15', '1000005', 'ALEWarningSign'],
|
|
|
|
\ ['16', '1000006', 'ALEErrorSign'],
|
|
|
|
\ ['2', '1000002', 'ALEWarningSign'],
|
|
|
|
\ ['3', '1000003', 'ALEErrorSign'],
|
|
|
|
\ ['4', '1000004', 'ALEWarningSign'],
|
|
|
|
\ ],
|
|
|
|
\ sort(ParseSigns())
|
|
|
|
|
2017-08-26 15:38:27 +00:00
|
|
|
Execute(Signs should be downgraded correctly):
|
|
|
|
call ale#sign#SetSigns(bufnr(''), [
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
|
|
|
|
\])
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['1', '1000001', 'ALEErrorSign'],
|
|
|
|
\ ['2', '1000002', 'ALEWarningSign'],
|
|
|
|
\ ],
|
|
|
|
\ sort(ParseSigns())
|
|
|
|
|
|
|
|
call ale#sign#SetSigns(bufnr(''), [
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
|
|
|
|
\])
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['1', '1000003', 'ALEWarningSign'],
|
|
|
|
\ ['2', '1000004', 'ALEInfoSign'],
|
|
|
|
\ ],
|
|
|
|
\ sort(ParseSigns())
|
|
|
|
|
|
|
|
Execute(Signs should be upgraded correctly):
|
|
|
|
call ale#sign#SetSigns(bufnr(''), [
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
|
|
|
|
\])
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['1', '1000001', 'ALEWarningSign'],
|
|
|
|
\ ['2', '1000002', 'ALEInfoSign'],
|
|
|
|
\ ],
|
|
|
|
\ sort(ParseSigns())
|
|
|
|
|
|
|
|
call ale#sign#SetSigns(bufnr(''), [
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
|
|
|
|
\])
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['1', '1000003', 'ALEErrorSign'],
|
|
|
|
\ ['2', '1000004', 'ALEWarningSign'],
|
|
|
|
\ ],
|
|
|
|
\ sort(ParseSigns())
|
|
|
|
|
|
|
|
Execute(It should be possible to clear signs with empty lists):
|
2017-10-03 09:00:16 +00:00
|
|
|
" We can fail to remove signs if there are multiple signs on one line,
|
|
|
|
" say after deleting lines in Vim, etc.
|
2020-03-15 06:58:38 +00:00
|
|
|
if has('nvim-0.4.2') || has('patch-8.1.614')
|
2024-01-14 11:29:10 +00:00
|
|
|
exec 'sign place 1000347 group=ale_signs line=3 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000348 group=ale_signs line=3 name=ALEWarningSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000349 group=ale_signs line=10 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000350 group=ale_signs line=10 name=ALEWarningSign buffer=' . bufnr('')
|
2019-09-25 08:15:16 +00:00
|
|
|
else
|
|
|
|
exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000348 line=3 name=ALEWarningSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000349 line=10 name=ALEErrorSign buffer=' . bufnr('')
|
|
|
|
exec 'sign place 1000350 line=10 name=ALEWarningSign buffer=' . bufnr('')
|
|
|
|
endif
|
2017-10-03 09:00:16 +00:00
|
|
|
|
|
|
|
call ale#sign#SetSigns(bufnr(''), [])
|
|
|
|
AssertEqual [], ParseSigns()
|
2023-09-16 21:22:01 +00:00
|
|
|
|
|
|
|
Execute(No exceptions should be thrown when setting signs for invalid buffers):
|
|
|
|
call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}])
|