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
1 changed files with 35 additions and 13 deletions

View File

@ -41,6 +41,7 @@ Before:
After: After:
Restore Restore
unlet! g:expected_results
unlet! b:ale_fixers unlet! b:ale_fixers
unlet! b:ale_enabled unlet! b:ale_enabled
" Clear the history we changed. " Clear the history we changed.
@ -67,6 +68,11 @@ Given foobar (Some imaginary filetype):
Execute(History should be set when commands are run): Execute(History should be set when commands are run):
AssertEqual 'foobar', &filetype AssertEqual 'foobar', &filetype
let g:expected_results = ['command', 'exit_code', 'job_id', 'status']
" 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#Lint()
call ale#engine#WaitForJobs(2000) call ale#engine#WaitForJobs(2000)
@ -76,7 +82,13 @@ Execute(History should be set when commands are run):
\) \)
AssertEqual 1, len(g:history) AssertEqual 1, len(g:history)
AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
if sort(keys(g:history[0])) == g:expected_results
break
endif
endfor
AssertEqual g:expected_results, sort(keys(g:history[0]))
if has('win32') if has('win32')
AssertEqual 'cmd /s/c "echo command history test"', g:history[0].command 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 AssertEqual 'foobar', &filetype
let g:ale_history_log_output = 1 let g:ale_history_log_output = 1
let g:expected_results = ['command history test']
" 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#Lint()
call ale#engine#WaitForJobs(2000) 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 1, len(g:history)
AssertEqual ['command history test'], g:history[0].output
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): 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''}') let b:ale_history = map(range(20), '{''status'': ''started'', ''job_id'': v:val, ''command'': ''foobar''}')