Re-run history tests, which can fail randomly

This commit is contained in:
w0rp 2018-07-15 21:20:56 +01:00
parent d3ed1e52ba
commit d9e12cb047
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83

View File

@ -41,6 +41,7 @@ Before:
After:
Restore
unlet! g:expected_results
unlet! b:ale_fixers
unlet! b:ale_enabled
" Clear the history we changed.
@ -67,16 +68,27 @@ Given foobar (Some imaginary filetype):
Execute(History should be set when commands are run):
AssertEqual 'foobar', &filetype
call ale#Lint()
call ale#engine#WaitForJobs(2000)
let g:expected_results = ['command', 'exit_code', 'job_id', 'status']
let g:history = filter(
\ copy(ale#history#Get(bufnr(''))),
\ 'v:val.job_id isnot# ''executable''',
\)
" Retry this test until it works. This one can randomly fail.
for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
let b:ale_history = []
call ale#Lint()
call ale#engine#WaitForJobs(2000)
AssertEqual 1, len(g:history)
AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
let g:history = filter(
\ copy(ale#history#Get(bufnr(''))),
\ 'v:val.job_id isnot# ''executable''',
\)
AssertEqual 1, len(g:history)
if sort(keys(g:history[0])) == g:expected_results
break
endif
endfor
AssertEqual g:expected_results, sort(keys(g:history[0]))
if has('win32')
AssertEqual 'cmd /s/c "echo command history test"', g:history[0].command
@ -103,14 +115,24 @@ Execute(History should include command output if logging is enabled):
AssertEqual 'foobar', &filetype
let g:ale_history_log_output = 1
let g:expected_results = ['command history test']
call ale#Lint()
call ale#engine#WaitForJobs(2000)
" Retry this test until it works. This one can randomly fail.
for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
let b:ale_history = []
call ale#Lint()
call ale#engine#WaitForJobs(2000)
let g:history = ale#history#Get(bufnr(''))
let g:history = ale#history#Get(bufnr(''))
AssertEqual 1, len(g:history)
AssertEqual ['command history test'], g:history[0].output
AssertEqual 1, len(g:history)
if get(g:history[0], 'output', []) == g:expected_results
break
endif
endfor
AssertEqual g:expected_results, get(g:history[0], 'output', [])
Execute(History items should be popped after going over the max):
let b:ale_history = map(range(20), '{''status'': ''started'', ''job_id'': v:val, ''command'': ''foobar''}')