diff options
author | w0rp <devw0rp@gmail.com> | 2017-08-25 22:22:26 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-08-25 22:22:26 +0100 |
commit | cdd1ddffdb95151f5cb96fd2549eb9e44f2a2fcb (patch) | |
tree | 8835181a3f1fc0c11f92d531770181b833f7279b /test/test_history_saving.vader | |
parent | 8f8d015daeb2070b20c8296dd8488e706332b5b7 (diff) | |
download | ale-cdd1ddffdb95151f5cb96fd2549eb9e44f2a2fcb.zip |
Fix #876 - Save history in a separate buffer variable so history works when linting is disabled
Diffstat (limited to 'test/test_history_saving.vader')
-rw-r--r-- | test/test_history_saving.vader | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader index 8207d153..3b8fb2aa 100644 --- a/test/test_history_saving.vader +++ b/test/test_history_saving.vader @@ -2,6 +2,8 @@ Before: Save g:ale_max_buffer_history_size Save g:ale_history_log_output + unlet! b:ale_history + " 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. let g:current_shell = &shell @@ -26,6 +28,9 @@ Before: After: Restore + " Clear the history we changed. + unlet! b:ale_history + " Reset the shell back to what it was before. let &shell = g:current_shell unlet g:current_shell @@ -46,7 +51,7 @@ Execute(History should be set when commands are run): call ale#Lint() call ale#engine#WaitForJobs(2000) - let g:history = g:ale_buffer_info[bufnr('%')].history + let g:history = ale#history#Get(bufnr('')) AssertEqual 1, len(g:history) AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0])) @@ -64,7 +69,7 @@ Execute(History should be not set when disabled): call ale#Lint() call ale#engine#WaitForJobs(2000) - AssertEqual 0, len(g:ale_buffer_info[bufnr('%')].history) + AssertEqual [], ale#history#Get(bufnr('')) Execute(History should include command output if logging is enabled): AssertEqual 'foobar', &filetype @@ -74,35 +79,32 @@ Execute(History should include command output if logging is enabled): call ale#Lint() call ale#engine#WaitForJobs(2000) - let g:history = g:ale_buffer_info[bufnr('%')].history + let g:history = ale#history#Get(bufnr('')) AssertEqual 1, len(g:history) AssertEqual ['command history test'], g:history[0].output Execute(History items should be popped after going over the max): - let g:ale_buffer_info[1] = { - \ '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''}') - call ale#history#Add(1, 'started', 347, 'last command') + call ale#history#Add(bufnr(''), 'started', 347, 'last command') AssertEqual \ ( \ map(range(1, 19), '{''status'': ''started'', ''job_id'': v:val, ''command'': ''foobar''}') \ + [{'status': 'started', 'job_id': 347, 'command': 'last command'}] \ ), - \ g:ale_buffer_info[1].history + \ ale#history#Get(bufnr('')) Execute(Nothing should be added to history if the size is too low): let g:ale_max_buffer_history_size = 0 - let g:ale_buffer_info[1] = {'history': []} - call ale#history#Add(1, 'started', 347, 'last command') + call ale#history#Add(bufnr(''), 'started', 347, 'last command') - AssertEqual [], g:ale_buffer_info[1].history + AssertEqual [], ale#history#Get(bufnr('')) let g:ale_max_buffer_history_size = -2 call ale#history#Add(1, 'started', 347, 'last command') - AssertEqual [], g:ale_buffer_info[1].history + AssertEqual [], ale#history#Get(bufnr('')) |