/ test / test_deferred_command_string.vader
test_deferred_command_string.vader
 1  Before:
 2    Save g:ale_run_synchronously
 3    Save g:ale_emulate_job_failure
 4    Save g:ale_buffer_info
 5  
 6    let g:ale_run_synchronously = 1
 7    let g:ale_buffer_info = {}
 8    let b:ale_history = []
 9  
10    call ale#linter#Reset()
11    call ale#assert#SetUpLinterTestCommands()
12    call ale#linter#Define('foobar', {
13    \ 'name': 'lint_file_linter',
14    \ 'callback': 'LintFileCallback',
15    \ 'executable': has('win32') ? 'cmd' : 'echo',
16    \ 'command': {b -> ale#command#Run(b, 'echo', {-> ale#command#Run(b, 'echo', {-> 'foo'})})},
17    \ 'read_buffer': 0,
18    \})
19  
20    " Run the test commands in the shell.
21    let g:ale_run_synchronously_emulate_commands = 0
22  
23  After:
24    Restore
25  
26    call ale#assert#TearDownLinterTest()
27    unlet! g:ale_run_synchronously_callbacks
28  
29  Given foobar (Some imaginary filetype):
30  Execute(It should be possible to compute a command based on the result of other commands):
31    AssertLinter has('win32') ? 'cmd' : 'echo', 'foo'
32  
33    ALELint
34    call ale#test#FlushJobs()
35  
36    AssertEqual
37    \ 1,
38    \ len(filter(copy(b:ale_history), 'string(v:val.command) =~# ''foo'''))
39  
40  Execute(We should handle the deferered command failing):
41    let g:ale_emulate_job_failure = 1
42  
43    AssertLinter has('win32') ? 'cmd' : 'echo', 0
44  
45    ALELint
46    call ale#test#FlushJobs()
47  
48    AssertEqual
49    \ 0,
50    \ len(filter(copy(b:ale_history), 'string(v:val.command) =~# ''foo'''))