summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/test_history_saving.vader48
1 files changed, 35 insertions, 13 deletions
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader
index 8764b74c..375e96a1 100644
--- a/test/test_history_saving.vader
+++ b/test/test_history_saving.vader
@@ -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']
+
+ " 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 = filter(
+ \ copy(ale#history#Get(bufnr(''))),
+ \ 'v:val.job_id isnot# ''executable''',
+ \)
+
+ AssertEqual 1, len(g:history)
- let g:history = filter(
- \ copy(ale#history#Get(bufnr(''))),
- \ 'v:val.job_id isnot# ''executable''',
- \)
+ if sort(keys(g:history[0])) == g:expected_results
+ break
+ endif
+ endfor
- AssertEqual 1, len(g:history)
- AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
+ 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(''))
+
+ AssertEqual 1, len(g:history)
- let g:history = ale#history#Get(bufnr(''))
+ if get(g:history[0], 'output', []) == g:expected_results
+ break
+ endif
+ endfor
- AssertEqual 1, len(g:history)
- AssertEqual ['command history test'], g:history[0].output
+ 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''}')