2017-02-15 21:36:16 +00:00
|
|
|
Before:
|
2017-08-13 21:27:01 +00:00
|
|
|
Save g:ale_buffer_info
|
2017-08-26 15:38:27 +00:00
|
|
|
Save g:ale_set_signs
|
|
|
|
Save g:ale_set_lists_synchronously
|
2017-10-28 14:41:14 +00:00
|
|
|
Save g:ale_run_synchronously
|
2017-12-01 17:12:16 +00:00
|
|
|
Save g:ale_pattern_options
|
|
|
|
Save g:ale_pattern_options_enabled
|
2018-03-25 11:57:08 +00:00
|
|
|
Save g:ale_set_balloons
|
2017-08-26 15:38:27 +00:00
|
|
|
|
|
|
|
let g:ale_set_signs = 1
|
|
|
|
let g:ale_set_lists_synchronously = 1
|
2017-10-28 18:36:16 +00:00
|
|
|
let g:ale_run_synchronously = 1
|
2017-12-01 17:12:16 +00:00
|
|
|
let g:ale_pattern_options = {}
|
|
|
|
let g:ale_pattern_options_enabled = 1
|
2018-05-11 10:07:16 +00:00
|
|
|
let g:ale_set_balloons =
|
|
|
|
\ has('balloon_eval') && has('gui_running') ||
|
|
|
|
\ has('balloon_eval_term') && !has('gui_running')
|
2017-10-28 18:36:16 +00:00
|
|
|
|
|
|
|
unlet! b:ale_enabled
|
2017-08-13 21:27:01 +00:00
|
|
|
|
|
|
|
let g:ale_buffer_info = {}
|
2017-02-15 21:36:16 +00:00
|
|
|
let g:expected_loclist = [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'foo bar',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
|
|
|
\}]
|
|
|
|
let g:expected_groups = [
|
|
|
|
\ 'ALECleanupGroup',
|
2018-06-20 12:35:57 +00:00
|
|
|
\ 'ALEEvents',
|
2017-02-15 21:36:16 +00:00
|
|
|
\ 'ALEHighlightBufferGroup',
|
|
|
|
\]
|
|
|
|
|
|
|
|
function! ToggleTestCallback(buffer, output)
|
|
|
|
return [{
|
|
|
|
\ 'bufnr': a:buffer,
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
2017-05-12 20:16:15 +00:00
|
|
|
\ 'text': 'foo bar',
|
2017-02-15 21:36:16 +00:00
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\}]
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ParseAuGroups()
|
|
|
|
redir => l:output
|
|
|
|
silent exec 'autocmd'
|
|
|
|
redir end
|
|
|
|
|
|
|
|
let l:results = []
|
|
|
|
|
|
|
|
for l:line in split(l:output, "\n")
|
2018-06-20 12:35:57 +00:00
|
|
|
let l:match = matchlist(l:line, '^ALE[a-zA-Z]\+')
|
2017-02-15 21:36:16 +00:00
|
|
|
|
2017-08-13 21:27:01 +00:00
|
|
|
" We don't care about some groups here.
|
2017-02-15 21:36:16 +00:00
|
|
|
if !empty(l:match)
|
2017-07-07 22:47:41 +00:00
|
|
|
\&& l:match[0] !=# 'ALECompletionGroup'
|
|
|
|
\&& l:match[0] !=# 'ALEBufferFixGroup'
|
2017-08-13 21:27:01 +00:00
|
|
|
\&& l:match[0] !=# 'ALEPatternOptionsGroup'
|
2017-02-15 21:36:16 +00:00
|
|
|
call add(l:results, l:match[0])
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
call uniq(sort(l:results))
|
|
|
|
|
|
|
|
return l:results
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'ToggleTestCallback',
|
2017-10-23 22:09:40 +00:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
2017-05-12 20:16:15 +00:00
|
|
|
\ 'command': 'echo',
|
|
|
|
\ 'read_buffer': 0,
|
2017-02-15 21:36:16 +00:00
|
|
|
\})
|
|
|
|
|
2017-08-26 15:38:27 +00:00
|
|
|
sign unplace *
|
|
|
|
|
2017-02-15 21:36:16 +00:00
|
|
|
After:
|
2017-08-13 21:27:01 +00:00
|
|
|
Restore
|
|
|
|
|
2017-02-15 21:36:16 +00:00
|
|
|
unlet! g:expected_loclist
|
|
|
|
unlet! g:expected_groups
|
2017-10-28 18:36:16 +00:00
|
|
|
unlet! b:ale_enabled
|
|
|
|
unlet! g:output
|
2017-02-15 21:36:16 +00:00
|
|
|
|
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
" Toggle ALE back on if we fail when it's disabled.
|
|
|
|
if !g:ale_enabled
|
|
|
|
ALEToggle
|
|
|
|
endif
|
|
|
|
|
|
|
|
delfunction ToggleTestCallback
|
|
|
|
delfunction ParseAuGroups
|
|
|
|
|
2017-10-28 18:36:16 +00:00
|
|
|
call setloclist(0, [])
|
|
|
|
sign unplace *
|
|
|
|
call clearmatches()
|
|
|
|
|
2017-02-15 21:36:16 +00:00
|
|
|
Given foobar (Some imaginary filetype):
|
|
|
|
foo
|
|
|
|
bar
|
|
|
|
baz
|
|
|
|
|
|
|
|
Execute(ALEToggle should reset everything and then run again):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2017-02-15 21:36:16 +00:00
|
|
|
|
|
|
|
" First check that everything is there...
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
2017-08-26 15:38:27 +00:00
|
|
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
2017-02-15 21:36:16 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
|
|
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
|
|
|
AssertEqual g:expected_groups, ParseAuGroups()
|
2017-07-07 22:47:41 +00:00
|
|
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
2017-02-15 21:36:16 +00:00
|
|
|
|
|
|
|
" Now Toggle ALE off.
|
|
|
|
ALEToggle
|
|
|
|
|
|
|
|
" Everything should be cleared.
|
2017-07-07 22:47:41 +00:00
|
|
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
|
|
|
AssertEqual [], getloclist(0), 'The loclist was not cleared'
|
2017-08-26 15:38:27 +00:00
|
|
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
2017-07-07 22:47:41 +00:00
|
|
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
2018-06-20 12:35:57 +00:00
|
|
|
AssertEqual g:expected_groups, ParseAuGroups()
|
2017-02-15 21:36:16 +00:00
|
|
|
|
|
|
|
" Toggle ALE on, everything should be set up and run again.
|
|
|
|
ALEToggle
|
|
|
|
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
2017-08-26 15:38:27 +00:00
|
|
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
2017-02-15 21:36:16 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
|
|
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
|
|
|
AssertEqual g:expected_groups, ParseAuGroups()
|
2017-07-07 22:47:41 +00:00
|
|
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
2017-08-13 21:27:01 +00:00
|
|
|
|
|
|
|
Execute(ALEToggle should skip filename keys and preserve them):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
|
|
|
let g:ale_buffer_info['/foo/bar/baz.txt'] = {
|
|
|
|
\ 'job_list': [],
|
|
|
|
\ 'active_linter_list': [],
|
|
|
|
\ 'loclist': [],
|
|
|
|
\ 'temporary_file_list': [],
|
|
|
|
\ 'temporary_directory_list': [],
|
|
|
|
\ 'history': [],
|
|
|
|
\}
|
|
|
|
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2017-08-13 21:27:01 +00:00
|
|
|
|
|
|
|
" Now Toggle ALE off.
|
|
|
|
ALEToggle
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'job_list': [],
|
|
|
|
\ 'active_linter_list': [],
|
|
|
|
\ 'loclist': [],
|
|
|
|
\ 'temporary_file_list': [],
|
|
|
|
\ 'temporary_directory_list': [],
|
|
|
|
\ 'history': [],
|
|
|
|
\ },
|
|
|
|
\ get(g:ale_buffer_info, '/foo/bar/baz.txt', {})
|
|
|
|
|
|
|
|
" Toggle ALE on again.
|
|
|
|
ALEToggle
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'job_list': [],
|
|
|
|
\ 'active_linter_list': [],
|
|
|
|
\ 'loclist': [],
|
|
|
|
\ 'temporary_file_list': [],
|
|
|
|
\ 'temporary_directory_list': [],
|
|
|
|
\ 'history': [],
|
|
|
|
\ },
|
|
|
|
\ get(g:ale_buffer_info, '/foo/bar/baz.txt', {})
|
2017-10-28 14:41:14 +00:00
|
|
|
|
|
|
|
Execute(ALEDisable should reset everything and stay disabled):
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2017-10-28 14:41:14 +00:00
|
|
|
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
|
|
|
|
ALEDisable
|
|
|
|
|
|
|
|
AssertEqual [], getloclist(0)
|
|
|
|
AssertEqual 0, g:ale_enabled
|
|
|
|
|
|
|
|
ALEDisable
|
|
|
|
|
|
|
|
AssertEqual [], getloclist(0)
|
|
|
|
AssertEqual 0, g:ale_enabled
|
|
|
|
|
|
|
|
Execute(ALEEnable should enable ALE and lint again):
|
|
|
|
let g:ale_enabled = 0
|
|
|
|
|
|
|
|
ALEEnable
|
|
|
|
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
AssertEqual 1, g:ale_enabled
|
2017-10-28 18:36:16 +00:00
|
|
|
|
2017-10-29 17:03:29 +00:00
|
|
|
Execute(ALEReset should reset everything for a buffer):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2017-10-29 17:03:29 +00:00
|
|
|
|
|
|
|
" First check that everything is there...
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
|
|
|
AssertEqual
|
|
|
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
|
|
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
|
|
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
|
|
|
|
|
|
|
" Now Toggle ALE off.
|
|
|
|
ALEReset
|
|
|
|
|
|
|
|
" Everything should be cleared.
|
|
|
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
|
|
|
AssertEqual [], getloclist(0), 'The loclist was not cleared'
|
|
|
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
|
|
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
|
|
|
|
|
|
|
AssertEqual 1, g:ale_enabled
|
|
|
|
|
2017-10-28 18:36:16 +00:00
|
|
|
Execute(ALEToggleBuffer should reset everything and then run again):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2017-10-28 18:36:16 +00:00
|
|
|
|
|
|
|
" First check that everything is there...
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
|
|
|
AssertEqual
|
|
|
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
|
|
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
|
|
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
|
|
|
|
|
|
|
" Now Toggle ALE off.
|
|
|
|
ALEToggleBuffer
|
|
|
|
|
|
|
|
" Everything should be cleared.
|
|
|
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
|
|
|
AssertEqual [], getloclist(0), 'The loclist was not cleared'
|
|
|
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
|
|
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
|
|
|
|
|
|
|
" Toggle ALE on, everything should be set up and run again.
|
|
|
|
ALEToggleBuffer
|
|
|
|
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
|
|
|
AssertEqual
|
|
|
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
|
|
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
|
|
|
AssertEqual g:expected_groups, ParseAuGroups()
|
|
|
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
|
|
|
|
|
|
|
Execute(ALEDisableBuffer should reset everything and stay disabled):
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2017-10-28 18:36:16 +00:00
|
|
|
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
|
|
|
|
ALEDisableBuffer
|
|
|
|
|
|
|
|
AssertEqual [], getloclist(0)
|
|
|
|
AssertEqual 0, b:ale_enabled
|
|
|
|
|
|
|
|
Execute(ALEEnableBuffer should enable ALE and lint again):
|
|
|
|
let b:ale_enabled = 0
|
|
|
|
|
|
|
|
ALEEnableBuffer
|
|
|
|
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
AssertEqual 1, b:ale_enabled
|
|
|
|
|
|
|
|
Execute(ALEEnableBuffer should complain when ALE is disabled globally):
|
|
|
|
let g:ale_enabled = 0
|
|
|
|
let b:ale_enabled = 0
|
|
|
|
|
|
|
|
redir => g:output
|
|
|
|
ALEEnableBuffer
|
|
|
|
redir END
|
|
|
|
|
|
|
|
AssertEqual [], getloclist(0)
|
|
|
|
AssertEqual 0, b:ale_enabled
|
|
|
|
AssertEqual 0, g:ale_enabled
|
|
|
|
AssertEqual
|
|
|
|
\ 'ALE cannot be enabled locally when disabled globally',
|
|
|
|
\ join(split(g:output))
|
2017-10-29 17:03:29 +00:00
|
|
|
|
|
|
|
Execute(ALEResetBuffer should reset everything for a buffer):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
2018-06-28 12:53:49 +00:00
|
|
|
ALELint
|
2017-10-29 17:03:29 +00:00
|
|
|
|
|
|
|
" First check that everything is there...
|
|
|
|
AssertEqual g:expected_loclist, getloclist(0)
|
|
|
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
|
|
|
AssertEqual
|
|
|
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
|
|
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
|
|
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
|
|
|
|
|
|
|
" Now Toggle ALE off.
|
|
|
|
ALEResetBuffer
|
|
|
|
|
|
|
|
" Everything should be cleared.
|
|
|
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
|
|
|
AssertEqual [], getloclist(0), 'The loclist was not cleared'
|
|
|
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
|
|
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
|
|
|
|
|
|
|
AssertEqual 1, g:ale_enabled
|
|
|
|
AssertEqual 1, get(b:, 'ale_enabled', 1)
|
2018-03-25 11:57:08 +00:00
|
|
|
|
|
|
|
Execute(Disabling ALE should disable balloons):
|
|
|
|
" These tests won't run in the console, but we can run them manually in GVim.
|
2018-05-11 10:07:16 +00:00
|
|
|
if has('balloon_eval') && has('gui_running') ||
|
|
|
|
\ has('balloon_eval_term') && !has('gui_running')
|
2018-03-25 11:57:08 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
" Enable balloons, so we can check the expr value.
|
|
|
|
call ale#balloon#Enable()
|
|
|
|
|
|
|
|
AssertEqual 1, &ballooneval
|
|
|
|
AssertEqual 'ale#balloon#Expr()', &balloonexpr
|
|
|
|
|
|
|
|
" Toggle ALE off.
|
|
|
|
ALEToggle
|
|
|
|
|
|
|
|
" The balloon settings should be reset.
|
|
|
|
AssertEqual 0, &ballooneval
|
|
|
|
AssertEqual '', &balloonexpr
|
|
|
|
endif
|
|
|
|
|
|
|
|
Execute(Enabling ALE should enable balloons if the setting is on):
|
2018-05-11 10:07:16 +00:00
|
|
|
if has('balloon_eval') && has('gui_running') ||
|
|
|
|
\ has('balloon_eval_term') && !has('gui_running')
|
2018-03-25 11:57:08 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
call ale#balloon#Disable()
|
|
|
|
ALEDisable
|
|
|
|
let g:ale_set_balloons = 0
|
|
|
|
ALEEnable
|
|
|
|
|
|
|
|
AssertEqual 0, &ballooneval
|
|
|
|
AssertEqual '', &balloonexpr
|
|
|
|
|
|
|
|
ALEDisable
|
|
|
|
let g:ale_set_balloons = 1
|
|
|
|
ALEEnable
|
|
|
|
|
|
|
|
AssertEqual 1, &ballooneval
|
|
|
|
AssertEqual 'ale#balloon#Expr()', &balloonexpr
|
|
|
|
endif
|