Make the test for the history more reliable

This commit is contained in:
w0rp 2017-06-06 19:54:10 +01:00
parent 9dadde190e
commit ef86a8a389
1 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,7 @@
Before: Before:
Save g:ale_max_buffer_history_size
Save g:ale_history_log_output
" Temporarily set the shell to /bin/sh, if it isn't already set that way. " Temporarily set the shell to /bin/sh, if it isn't already set that way.
" This will make it so the test works when running it directly. " This will make it so the test works when running it directly.
let g:current_shell = &shell let g:current_shell = &shell
@ -6,6 +9,7 @@ Before:
let g:history = [] let g:history = []
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
let g:ale_max_buffer_history_size = 20 let g:ale_max_buffer_history_size = 20
let g:ale_history_log_output = 0
function! CollectResults(buffer, output) function! CollectResults(buffer, output)
return [] return []
@ -15,11 +19,13 @@ Before:
\ 'name': 'testlinter', \ 'name': 'testlinter',
\ 'callback': 'CollectResults', \ 'callback': 'CollectResults',
\ 'executable': 'echo', \ 'executable': 'echo',
\ 'command': 'echo command history test', \ 'command': '/bin/sh -c ''echo command history test''',
\ 'read_buffer': 0, \ 'read_buffer': 0,
\}) \})
After: After:
Restore
" Reset the shell back to what it was before. " Reset the shell back to what it was before.
let &shell = g:current_shell let &shell = g:current_shell
unlet g:current_shell unlet g:current_shell
@ -44,7 +50,7 @@ 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])) AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
AssertEqual ['/bin/sh', '-c', 'echo command history test'], g:history[0].command AssertEqual ['/bin/sh', '-c', '/bin/sh -c ''echo command history test'''], g:history[0].command
AssertEqual 'finished', g:history[0].status AssertEqual 'finished', g:history[0].status
AssertEqual 0, g:history[0].exit_code AssertEqual 0, g:history[0].exit_code
" The Job ID will change each time, but we can check the type. " The Job ID will change each time, but we can check the type.