mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-19 17:42:57 +08:00
#107 Stop jobs when buffers close
This commit is contained in:
@@ -1,32 +1,21 @@
|
||||
Before:
|
||||
let g:buffer = bufnr('%')
|
||||
let g:ale_buffer_count_map = {
|
||||
\ g:buffer: [1, 1],
|
||||
\ 10347: [1, 1],
|
||||
\}
|
||||
let g:ale_buffer_loclist_map = {
|
||||
\ g:buffer : [],
|
||||
\ 10347: [],
|
||||
\}
|
||||
let g:ale_buffer_should_reset_map = {
|
||||
\ g:buffer : 1,
|
||||
\ 10347: 1,
|
||||
\}
|
||||
let g:ale_buffer_sign_dummy_map = {
|
||||
\ g:buffer : 1,
|
||||
\ 10347: 1,
|
||||
|
||||
let g:ale_buffer_info = {
|
||||
\ g:buffer : {},
|
||||
\ 10347: {},
|
||||
\}
|
||||
|
||||
After:
|
||||
unlet! g:buffer
|
||||
let g:ale_buffer_count_map = {}
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
let g:ale_buffer_should_reset_map = {}
|
||||
let g:ale_buffer_sign_dummy_map = {}
|
||||
let g:ale_buffer_info = {}
|
||||
|
||||
Execute('ALE globals should be cleared when the buffer is closed.'):
|
||||
:q!
|
||||
AssertEqual {10347: [1, 1]}, g:ale_buffer_count_map
|
||||
AssertEqual {10347: []}, g:ale_buffer_loclist_map
|
||||
AssertEqual {10347: 1}, g:ale_buffer_should_reset_map
|
||||
AssertEqual {10347: 1}, g:ale_buffer_sign_dummy_map
|
||||
AssertEqual {10347: {}}, g:ale_buffer_info
|
||||
|
||||
40
test/test_linting_sets_signs.vader
Normal file
40
test/test_linting_sets_signs.vader
Normal file
@@ -0,0 +1,40 @@
|
||||
Given javascript (Some JavaScript with problems):
|
||||
var y = 3+3;
|
||||
var y = 3
|
||||
|
||||
Before:
|
||||
sign unplace *
|
||||
let g:actual_sign_list = []
|
||||
let g:expected_sign_list = [
|
||||
\ ['1', 'ALEWarningSign'],
|
||||
\ ['2', 'ALEErrorSign'],
|
||||
\]
|
||||
|
||||
function! g:CollectSigns()
|
||||
redir => l:output
|
||||
silent exec 'sign place'
|
||||
redir END
|
||||
|
||||
for l:line in split(l:output, "\n")
|
||||
let l:match = matchlist(l:line, 'line=\(\d\+\).*name=\(ALE[a-zA-Z]\+\)')
|
||||
|
||||
if len(l:match) > 0
|
||||
call add(g:actual_sign_list, [l:match[1], l:match[2]])
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
After:
|
||||
sign unplace *
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
let g:ale_buffer_info = {}
|
||||
delfunction g:CollectSigns
|
||||
unlet g:actual_sign_list
|
||||
unlet g:expected_sign_list
|
||||
|
||||
Execute(The signs should be updated after linting is done):
|
||||
call ale#Lint()
|
||||
call ale#engine#WaitForJobs(2000)
|
||||
call g:CollectSigns()
|
||||
|
||||
AssertEqual g:expected_sign_list, g:actual_sign_list
|
||||
@@ -1,49 +1,59 @@
|
||||
Before:
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
||||
|
||||
After:
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
let g:ale_buffer_info = {}
|
||||
|
||||
Execute (Count should be 0 when data is empty):
|
||||
let g:ale_buffer_info = {}
|
||||
AssertEqual [0, 0], ale#statusline#Count(bufnr('%'))
|
||||
|
||||
Before:
|
||||
let g:ale_buffer_count_map = {'44': [1, 2]}
|
||||
|
||||
Execute (Count should read data from the cache):
|
||||
let g:ale_buffer_info = {'44': {'count': [1, 2]}}
|
||||
AssertEqual [1, 2], ale#statusline#Count(44)
|
||||
|
||||
Execute (Update the cache with new data):
|
||||
Execute (The count should be correct after an update):
|
||||
let g:ale_buffer_info = {'44': {}}
|
||||
call ale#statusline#Update(44, [])
|
||||
|
||||
Then (The cache should reflect the new data):
|
||||
AssertEqual [0, 0], ale#statusline#Count(44)
|
||||
|
||||
Before:
|
||||
let g:ale_buffer_loclist_map = {'1': [{'lnum': 1, 'bufnr': 1, 'vcol': 0, 'linter_name': 'testlinter', 'nr': -1, 'type': 'E', 'col': 1, 'text': 'Test Error'}]}
|
||||
|
||||
Execute (Count should be match the loclist):
|
||||
AssertEqual [1, 0], ale#statusline#Count(1)
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
let g:ale_buffer_loclist_map = {bufnr('%'): [
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'bufnr': 1,
|
||||
\ 'vcol': 0,
|
||||
\ 'linter_name': 'testlinter',
|
||||
\ 'nr': -1,
|
||||
\ 'type': 'E',
|
||||
\ 'col': 1,
|
||||
\ 'text': 'Test Error',
|
||||
\ },
|
||||
\]}
|
||||
AssertEqual [1, 0], ale#statusline#Count(bufnr('%'))
|
||||
|
||||
Execute (Output should be empty for non-existant buffer):
|
||||
AssertEqual [0, 0], ale#statusline#Count(9001)
|
||||
|
||||
Before:
|
||||
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
||||
|
||||
Execute (Given some errors):
|
||||
Execute (Statusline is formatted to the users preference for just errors):
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'E'}])
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual '2E', ale#statusline#Status()
|
||||
|
||||
Execute (Given some warnings):
|
||||
Execute (Statusline is formatted to the users preference for just warnings):
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [{'type': 'W'}, {'type': 'W'}, {'type': 'W'}])
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual '3W', ale#statusline#Status()
|
||||
|
||||
Execute (Given some warnings, and errors):
|
||||
Execute (Statusline is formatted to the users preference for errors and warnings):
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'W'}, {'type': 'W'}])
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual '1E 2W', ale#statusline#Status()
|
||||
|
||||
Execute (Given a lack of data):
|
||||
Execute (Statusline is formatted to the users preference for no errors or warnings):
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [])
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual 'OKIE', ale#statusline#Status()
|
||||
|
||||
Reference in New Issue
Block a user