summaryrefslogtreecommitdiff
path: root/test/fix
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-22 22:32:53 +0000
committerw0rp <devw0rp@gmail.com>2017-11-22 22:32:53 +0000
commitd07b5b71a460eb0eeb5956f0da9dc409c24723aa (patch)
treec2356b5082b154d8c3ccac13b1fc831273ff302f /test/fix
parentfbfde6968a562abb88373588687d9b26cac68469 (diff)
downloadale-d07b5b71a460eb0eeb5956f0da9dc409c24723aa.zip
Add support for post-processing fixer output
Diffstat (limited to 'test/fix')
-rw-r--r--test/fix/test_ale_fix.vader30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader
index 47932930..0987416b 100644
--- a/test/fix/test_ale_fix.vader
+++ b/test/fix/test_ale_fix.vader
@@ -133,6 +133,25 @@ Before:
return empty(l:lines) ? '' : l:lines[-1]
endfunction
+ function! FixWithJSONPostProcessing(buffer) abort
+ let l:ProcessWith = 'JSONPostProcessor'
+
+ " Test with lambdas where support is available.
+ if has('lambda')
+ let l:ProcessWith = {buffer, output -> JSONPostProcessor(buffer, output)}
+ endif
+
+ return {
+ \ 'command': 'echo ' . ale#Escape('{"output": ["x", "y", "z"]}'),
+ \ 'read_buffer': 0,
+ \ 'process_with': l:ProcessWith,
+ \}
+ endfunction
+
+ function! JSONPostProcessor(buffer, output) abort
+ return json_decode(a:output[0]).output
+ endfunction
+
After:
Restore
unlet! g:ale_run_synchronously
@@ -160,6 +179,8 @@ After:
delfunction GetLastMessage
delfunction IgnoredEmptyOutput
delfunction EchoLineNoPipe
+ delfunction FixWithJSONPostProcessing
+ delfunction JSONPostProcessor
call ale#test#RestoreDirectory()
@@ -612,3 +633,12 @@ Execute(A temporary file shouldn't be piped into the command when disabled):
Expect(The new line should be used):
new line
+
+Execute(Post-processing should work):
+ let g:ale_fixers.testft = ['FixWithJSONPostProcessing']
+ ALEFix
+
+Expect(The lines in the JSON should be used):
+ x
+ y
+ z