diff options
author | w0rp <devw0rp@gmail.com> | 2019-02-21 21:24:41 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-02-21 21:24:41 +0000 |
commit | ffa45fa3fb44ade28c64aa8f0a21acd71c903a2a (patch) | |
tree | 350f4b45b17a1862844a14856c4063c0d219f0bd /test | |
parent | a8b987a1c31f297622f0038230d23404e7c2ad50 (diff) | |
download | ale-ffa45fa3fb44ade28c64aa8f0a21acd71c903a2a.zip |
#2132 - Implement deferred command handling for linters
Diffstat (limited to 'test')
-rw-r--r-- | test/test_deferred_command_string.vader | 46 | ||||
-rw-r--r-- | test/test_deferred_executable_string.vader | 16 | ||||
-rw-r--r-- | test/test_linter_defintion_processing.vader | 10 |
3 files changed, 69 insertions, 3 deletions
diff --git a/test/test_deferred_command_string.vader b/test/test_deferred_command_string.vader new file mode 100644 index 00000000..4d0c8977 --- /dev/null +++ b/test/test_deferred_command_string.vader @@ -0,0 +1,46 @@ +Before: + Save g:ale_run_synchronously + Save g:ale_emulate_job_failure + Save g:ale_buffer_info + + let g:ale_run_synchronously = 1 + let g:ale_buffer_info = {} + let b:ale_history = [] + + call ale#linter#Reset() + call ale#assert#SetUpLinterTestCommands() + call ale#linter#Define('foobar', { + \ 'name': 'lint_file_linter', + \ 'callback': 'LintFileCallback', + \ 'executable': 'echo', + \ 'command': {b -> ale#command#Run(b, 'echo', {-> ale#command#Run(b, 'echo', {-> 'foo'})})}, + \ 'read_buffer': 0, + \}) + +After: + Restore + + call ale#assert#TearDownLinterTest() + +Given foobar (Some imaginary filetype): +Execute(It should be possible to compute an executable to check based on the result of commands): + AssertLinter 'echo', 'foo' + + ALELint + call ale#test#FlushJobs() + + AssertEqual + \ 1, + \ len(filter(copy(b:ale_history), 'string(v:val.command) =~# ''foo''')) + +Execute(It handle the deferred command failing): + let g:ale_emulate_job_failure = 1 + + AssertLinter 'echo', 0 + + ALELint + call ale#test#FlushJobs() + + AssertEqual + \ 0, + \ len(filter(copy(b:ale_history), 'string(v:val.command) =~# ''foo''')) diff --git a/test/test_deferred_executable_string.vader b/test/test_deferred_executable_string.vader index ad2e752b..3bdc5251 100644 --- a/test/test_deferred_executable_string.vader +++ b/test/test_deferred_executable_string.vader @@ -1,9 +1,11 @@ Before: Save g:ale_run_synchronously + Save g:ale_emulate_job_failure Save g:ale_buffer_info let g:ale_run_synchronously = 1 let g:ale_buffer_info = {} + let b:ale_history = [] call ale#linter#Reset() call ale#assert#SetUpLinterTestCommands() @@ -22,8 +24,6 @@ After: Given foobar (Some imaginary filetype): Execute(It should be possible to compute an executable to check based on the result of commands): - let b:ale_history = [] - AssertLinter 'foo', 'echo' ALELint @@ -32,3 +32,15 @@ Execute(It should be possible to compute an executable to check based on the res AssertEqual \ [{'status': 0, 'job_id': 'executable', 'command': 'foo'}], \ filter(copy(b:ale_history), 'v:val.job_id is# ''executable''') + +Execute(It handle the deferred command failing): + let g:ale_emulate_job_failure = 1 + + AssertLinter 0, 'echo' + + ALELint + call ale#test#FlushJobs() + + AssertEqual + \ [], + \ filter(copy(b:ale_history), 'v:val.job_id is# ''executable''') diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader index 321c6212..0f54cf0e 100644 --- a/test/test_linter_defintion_processing.vader +++ b/test/test_linter_defintion_processing.vader @@ -82,7 +82,15 @@ Execute (PreProcess should throw when command is not a string): \ 'executable': 'echo', \ 'command': [], \}) - AssertEqual '`command` must be a string if defined', g:vader_exception + AssertEqual '`command` must be a String or Function if defined', g:vader_exception + +Execute (PreProcess should allow command to be a callback): + call ale#linter#PreProcess('testft', { + \ 'name': 'foo', + \ 'callback': 'SomeFunction', + \ 'executable': 'echo', + \ 'command': function('type'), + \}) Execute (PreProcess should throw when command_callback is not a callback): AssertThrows call ale#linter#PreProcess('testft', { |