Experimental code for showing results as soon as each linter completes
This commit is contained in:
@@ -126,30 +126,32 @@ Execute(The current signs should be set for running a job):
|
||||
|
||||
|
||||
Execute(Loclist items with sign_id values should be kept):
|
||||
exec 'sign place 1000347 line=15 name=ALEErrorSign buffer=' . bufnr('%')
|
||||
exec 'sign place 1000348 line=16 name=ALEWarningSign buffer=' . bufnr('%')
|
||||
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('%')
|
||||
|
||||
let g:loclist = [
|
||||
\ {'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000347},
|
||||
\ {'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000348},
|
||||
\ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c'},
|
||||
\ {'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
|
||||
\ {'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000349},
|
||||
\ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
|
||||
\ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
|
||||
\ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
|
||||
\ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
||||
\]
|
||||
|
||||
call ale#sign#SetSigns(bufnr('%'), g:loclist)
|
||||
call ale#sign#RemoveDummySignIfNeeded(bufnr('%'))
|
||||
|
||||
" Line numbers should be changed, sign_id values should be replaced,
|
||||
" and items should be sorted again.
|
||||
" Sign IDs from before should be kept, and new signs should use
|
||||
" IDs that haven't been used yet.
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000001},
|
||||
\ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000002},
|
||||
\ {'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000003},
|
||||
\ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000003},
|
||||
\ {'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000004},
|
||||
\ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000004},
|
||||
\ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
|
||||
\ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000350},
|
||||
\ {'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000351},
|
||||
\ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000351},
|
||||
\ {'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000352},
|
||||
\ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000352},
|
||||
\ ],
|
||||
\ g:loclist
|
||||
|
||||
@@ -158,12 +160,14 @@ Execute(Loclist items with sign_id values should be kept):
|
||||
" now have new warnings.
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['3', '1000001', 'ALEErrorSign'],
|
||||
\ ['4', '1000002', 'ALEWarningSign'],
|
||||
\ ['15', '1000003', 'ALEErrorSign'],
|
||||
\ ['16', '1000004', 'ALEErrorSign'],
|
||||
\ ['15', '1000348', 'ALEErrorSign'],
|
||||
\ ['15', '1000351', 'ALEErrorSign'],
|
||||
\ ['16', '1000349', 'ALEWarningSign'],
|
||||
\ ['16', '1000352', 'ALEErrorSign'],
|
||||
\ ['3', '1000347', 'ALEErrorSign'],
|
||||
\ ['4', '1000350', 'ALEWarningSign'],
|
||||
\ ],
|
||||
\ ParseSigns()
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(No excpetions should be thrown when setting signs for invalid buffers):
|
||||
call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}])
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
Before:
|
||||
function! TestCallback(buffer, output)
|
||||
return [{
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': 2,
|
||||
\ 'vcol': 0,
|
||||
\ 'col': 3,
|
||||
\ 'text': a:output[0],
|
||||
\ 'type': 'E',
|
||||
\ 'nr': -1,
|
||||
\}]
|
||||
endfunction
|
||||
function! TestCallback2(buffer, output)
|
||||
return [{
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 4,
|
||||
\ 'text': a:output[0],
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
@@ -22,6 +25,7 @@ Before:
|
||||
After:
|
||||
let g:ale_buffer_info = {}
|
||||
delfunction TestCallback
|
||||
delfunction TestCallback2
|
||||
call ale#linter#Reset()
|
||||
|
||||
Given foobar (Some imaginary filetype):
|
||||
@@ -46,3 +50,31 @@ Execute(Linters should run with the default options):
|
||||
\ 'pattern': '',
|
||||
\ 'valid': 1,
|
||||
\ }], getloclist(0)
|
||||
|
||||
Execute(Previous errors should be removed when linters change):
|
||||
call ale#Lint()
|
||||
call ale#engine#WaitForJobs(2000)
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
call ale#linter#Define('foobar', {
|
||||
\ 'name': 'testlinter2',
|
||||
\ 'callback': 'TestCallback2',
|
||||
\ 'executable': 'echo',
|
||||
\ 'command': '/bin/sh -c ''echo baz boz''',
|
||||
\})
|
||||
|
||||
call ale#Lint()
|
||||
call ale#engine#WaitForJobs(2000)
|
||||
|
||||
AssertEqual [{
|
||||
\ 'bufnr': bufnr('%'),
|
||||
\ 'lnum': 3,
|
||||
\ 'vcol': 0,
|
||||
\ 'col': 4,
|
||||
\ 'text': 'baz boz',
|
||||
\ 'type': 'E',
|
||||
\ 'nr': -1,
|
||||
\ 'pattern': '',
|
||||
\ 'valid': 1,
|
||||
\ }], getloclist(0)
|
||||
|
||||
@@ -64,14 +64,17 @@ Execute(The quickfix window should open for just the loclist):
|
||||
|
||||
" It should not open for an empty list.
|
||||
call ale#list#SetLists(bufnr('%'), [])
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert !ale#list#IsQuickfixOpen()
|
||||
|
||||
" With a non-empty loclist, the window must open.
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert ale#list#IsQuickfixOpen()
|
||||
|
||||
" Clear the list and it should close again.
|
||||
call ale#list#SetLists(bufnr('%'), [])
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert !ale#list#IsQuickfixOpen()
|
||||
|
||||
Execute(The quickfix window height should be correct for the loclist):
|
||||
@@ -79,6 +82,7 @@ Execute(The quickfix window height should be correct for the loclist):
|
||||
let g:ale_list_window_size = 7
|
||||
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
|
||||
AssertEqual 7, GetQuickfixHeight()
|
||||
|
||||
@@ -87,6 +91,7 @@ Execute(The quickfix window height should be correct for the loclist with buffer
|
||||
let b:ale_list_window_size = 8
|
||||
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
|
||||
AssertEqual 8, GetQuickfixHeight()
|
||||
|
||||
@@ -96,13 +101,16 @@ Execute(The quickfix window should stay open for just the loclist):
|
||||
|
||||
" The window should stay open after even after it is made blank again.
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
call ale#list#SetLists(bufnr('%'), [])
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert ale#list#IsQuickfixOpen()
|
||||
|
||||
Execute(The quickfix window should not open by default when quickfix is on):
|
||||
let g:ale_set_quickfix = 1
|
||||
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert !ale#list#IsQuickfixOpen()
|
||||
|
||||
Execute(The quickfix window should open for the quickfix list):
|
||||
@@ -111,15 +119,18 @@ Execute(The quickfix window should open for the quickfix list):
|
||||
|
||||
" It should not open for an empty list.
|
||||
call ale#list#SetLists(bufnr('%'), [])
|
||||
Assert !ale#list#IsQuickfixOpen()
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was opened when the list was empty'
|
||||
|
||||
" With a non-empty quickfix list, the window must open.
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
Assert ale#list#IsQuickfixOpen()
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert ale#list#IsQuickfixOpen(), 'The quickfix window was closed when the list was not empty'
|
||||
|
||||
" Clear the list and it should close again.
|
||||
call ale#list#SetLists(bufnr('%'), [])
|
||||
Assert !ale#list#IsQuickfixOpen()
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was not closed when the list was empty'
|
||||
|
||||
Execute(The quickfix window should stay open for the quickfix list):
|
||||
let g:ale_set_quickfix = 1
|
||||
@@ -128,7 +139,9 @@ Execute(The quickfix window should stay open for the quickfix list):
|
||||
|
||||
" The window should stay open after even after it is made blank again.
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
call ale#list#SetLists(bufnr('%'), [])
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
Assert ale#list#IsQuickfixOpen()
|
||||
|
||||
Execute(The quickfix window height should be correct for the quickfix list):
|
||||
@@ -137,6 +150,7 @@ Execute(The quickfix window height should be correct for the quickfix list):
|
||||
let g:ale_list_window_size = 7
|
||||
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
|
||||
AssertEqual 7, GetQuickfixHeight()
|
||||
|
||||
@@ -146,5 +160,6 @@ Execute(The quickfix window height should be correct for the quickfix list with
|
||||
let b:ale_list_window_size = 8
|
||||
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
||||
|
||||
AssertEqual 8, GetQuickfixHeight()
|
||||
|
||||
Reference in New Issue
Block a user