summaryrefslogtreecommitdiff
path: root/test/test_ale_info.vader
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-06-21 02:26:41 +0100
committerw0rp <devw0rp@gmail.com>2018-06-21 02:26:41 +0100
commit22533f2c1f09bcf19dfba9e24a6a948c3d2716c0 (patch)
tree5864d887cc4adc0e5bc377f4b7bb8b3503c6facc /test/test_ale_info.vader
parent69eb2fe86adaba5276e20d01c690d7ddaa8a5f1a (diff)
downloadale-22533f2c1f09bcf19dfba9e24a6a948c3d2716c0.zip
Close #1522 - Show suggested fixers in :ALEInfo
Diffstat (limited to 'test/test_ale_info.vader')
-rw-r--r--test/test_ale_info.vader415
1 files changed, 257 insertions, 158 deletions
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 75078607..39a2a85a 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -57,6 +57,14 @@ Before:
let g:ale_fixers = {}
let g:ale_linter_aliases = {}
let g:ale_buffer_info = {}
+ let g:fixer_lines = [
+ \ ' Suggested Fixers: ',
+ \ ' ''foo'' - Fix things the foo way',
+ \]
+ let g:variables_lines = [
+ \ ' Linter Variables:',
+ \ '',
+ \]
let g:globals_lines = [
\ ' Global Variables:',
\ '',
@@ -129,6 +137,9 @@ Before:
call ale#test#SetDirectory('/testplugin/test')
+ call ale#fix#registry#Clear()
+ call ale#fix#registry#Add('foo', 'x', [], 'Fix things the foo way')
+
After:
Restore
@@ -138,6 +149,8 @@ After:
unlet! b:ale_history
unlet! b:ale_linters
unlet! g:output
+ unlet! g:fixer_lines
+ unlet! g:variables_lines
unlet! g:globals_string
unlet! g:command_header
unlet! g:ale_testft_testlinter1_foo
@@ -148,16 +161,21 @@ After:
delfunction CheckInfo
call ale#test#RestoreDirectory()
+ call ale#fix#registry#ResetToDefaults()
Given nolintersft (Empty buffer with no linters):
Execute (ALEInfo with no linters should return the right output):
- call CheckInfo([
- \ ' Current Filetype: nolintersft',
- \ 'Available Linters: []',
- \ ' Enabled Linters: []',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: nolintersft',
+ \ 'Available Linters: []',
+ \ ' Enabled Linters: []',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given (Empty buffer with no filetype):
Execute (ALEInfo should return buffer-local global ALE settings):
@@ -169,48 +187,64 @@ Execute (ALEInfo should return buffer-local global ALE settings):
\ index(g:globals_lines, 'let g:ale_linters = {}') + 1
\)
- call CheckInfo([
- \ ' Current Filetype: ',
- \ 'Available Linters: []',
- \ ' Enabled Linters: []',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: ',
+ \ 'Available Linters: []',
+ \ ' Enabled Linters: []',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given (Empty buffer with no filetype):
Execute (ALEInfo with no filetype should return the right output):
- call CheckInfo([
- \ ' Current Filetype: ',
- \ 'Available Linters: []',
- \ ' Enabled Linters: []',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: ',
+ \ 'Available Linters: []',
+ \ ' Enabled Linters: []',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft (Empty buffer):
Execute (ALEInfo with a single linter should return the right output):
call ale#linter#Define('testft', g:testlinter1)
- call CheckInfo([
- \ ' Current Filetype: testft',
- \ 'Available Linters: [''testlinter1'']',
- \ ' Enabled Linters: [''testlinter1'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft',
+ \ 'Available Linters: [''testlinter1'']',
+ \ ' Enabled Linters: [''testlinter1'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft (Empty buffer):
Execute (ALEInfo with two linters should return the right output):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft', g:testlinter2)
- call CheckInfo([
- \ ' Current Filetype: testft',
- \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft',
+ \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
+ \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft (Empty buffer):
Execute (ALEInfo should calculate enabled linters correctly):
@@ -221,39 +255,51 @@ Execute (ALEInfo should calculate enabled linters correctly):
let g:globals_lines[index(g:globals_lines, 'let g:ale_linters = {}')]
\ = 'let g:ale_linters = {''testft'': [''testlinter2'']}'
- call CheckInfo([
- \ ' Current Filetype: testft',
- \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Enabled Linters: [''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft',
+ \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
+ \ ' Enabled Linters: [''testlinter2'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft (Empty buffer):
Execute (ALEInfo should only return linters for current filetype):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
- \ ' Current Filetype: testft',
- \ 'Available Linters: [''testlinter1'']',
- \ ' Enabled Linters: [''testlinter1'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft',
+ \ 'Available Linters: [''testlinter1'']',
+ \ ' Enabled Linters: [''testlinter1'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo with compound filetypes should return linters for both of them):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
- \ ' Current Filetype: testft.testft2',
- \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft.testft2',
+ \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
+ \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should return appropriately named global variables):
@@ -265,17 +311,24 @@ Execute (ALEInfo should return appropriately named global variables):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
- \ ' Current Filetype: testft.testft2',
- \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \ 'let g:ale_testft2_testlinter2_bar = {''x'': ''y''}',
- \ 'let g:ale_testft2_testlinter2_foo = 123',
- \ 'let g:ale_testft_testlinter1_bar = [''abc'']',
- \ 'let g:ale_testft_testlinter1_foo = ''abc''',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft.testft2',
+ \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
+ \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + [
+ \ ' Linter Variables:',
+ \ '',
+ \ 'let g:ale_testft2_testlinter2_bar = {''x'': ''y''}',
+ \ 'let g:ale_testft2_testlinter2_foo = 123',
+ \ 'let g:ale_testft_testlinter1_bar = [''abc'']',
+ \ 'let g:ale_testft_testlinter1_foo = ''abc''',
+ \ ]
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Execute (ALEInfoToFile should write to a file correctly):
if filereadable(g:dir . '/ale-info-test-file')
@@ -292,17 +345,24 @@ Execute (ALEInfoToFile should write to a file correctly):
execute 'ALEInfoToFile ' . fnameescape(g:dir . '/ale-info-test-file')
- AssertEqual [
- \ ' Current Filetype: testft.testft2',
- \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \ 'let g:ale_testft2_testlinter2_bar = {''x'': ''y''}',
- \ 'let g:ale_testft2_testlinter2_foo = 123',
- \ 'let g:ale_testft_testlinter1_bar = [''abc'']',
- \ 'let g:ale_testft_testlinter1_foo = ''abc''',
- \] + g:globals_lines + g:command_header, readfile(g:dir . '/ale-info-test-file')
+ AssertEqual
+ \ [
+ \ ' Current Filetype: testft.testft2',
+ \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
+ \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + [
+ \ ' Linter Variables:',
+ \ '',
+ \ 'let g:ale_testft2_testlinter2_bar = {''x'': ''y''}',
+ \ 'let g:ale_testft2_testlinter2_foo = 123',
+ \ 'let g:ale_testft_testlinter1_bar = [''abc'']',
+ \ 'let g:ale_testft_testlinter1_foo = ''abc''',
+ \ ]
+ \ + g:globals_lines
+ \ + g:command_header,
+ \ readfile(g:dir . '/ale-info-test-file')
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should buffer-local linter variables):
@@ -312,15 +372,22 @@ Execute (ALEInfo should buffer-local linter variables):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
- \ ' Current Filetype: testft.testft2',
- \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \ 'let g:ale_testft2_testlinter2_foo = 123',
- \ 'let b:ale_testft2_testlinter2_foo = 456',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft.testft2',
+ \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
+ \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + [
+ \ ' Linter Variables:',
+ \ '',
+ \ 'let g:ale_testft2_testlinter2_foo = 123',
+ \ 'let b:ale_testft2_testlinter2_foo = 456',
+ \ ]
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should output linter aliases):
@@ -333,18 +400,25 @@ Execute (ALEInfo should output linter aliases):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
- \ ' Current Filetype: testft.testft2',
- \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Aliases:',
- \ '''testlinter1'' -> [''testftalias1'', ''testftalias2'']',
- \ '''testlinter2'' -> [''testftalias3'', ''testftalias4'']',
- \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \ 'let g:ale_testft2_testlinter2_foo = 123',
- \ 'let b:ale_testft2_testlinter2_foo = 456',
- \] + g:globals_lines + g:command_header)
+ call CheckInfo(
+ \ [
+ \ ' Current Filetype: testft.testft2',
+ \ 'Available Linters: [''testlinter1'', ''testlinter2'']',
+ \ ' Linter Aliases:',
+ \ '''testlinter1'' -> [''testftalias1'', ''testftalias2'']',
+ \ '''testlinter2'' -> [''testftalias3'', ''testftalias4'']',
+ \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
+ \ ]
+ \ + g:fixer_lines
+ \ + [
+ \ ' Linter Variables:',
+ \ '',
+ \ 'let g:ale_testft2_testlinter2_foo = 123',
+ \ 'let b:ale_testft2_testlinter2_foo = 456',
+ \ ]
+ \ + g:globals_lines
+ \ + g:command_header
+ \)
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should return command history):
@@ -356,17 +430,22 @@ Execute (ALEInfo should return command history):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
+ call CheckInfo(
+ \ [
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header + [
- \ '',
- \ '(started) ''first command''',
- \ '(started) [''/bin/bash'', ''\c'', ''last command'']',
- \])
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \ + [
+ \ '',
+ \ '(started) ''first command''',
+ \ '(started) [''/bin/bash'', ''\c'', ''last command'']',
+ \ ]
+ \)
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo command history should print exit codes correctly):
@@ -378,17 +457,22 @@ Execute (ALEInfo command history should print exit codes correctly):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
+ call CheckInfo(
+ \ [
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header + [
- \ '',
- \ '(finished - exit code 0) ''first command''',
- \ '(finished - exit code 1) [''/bin/bash'', ''\c'', ''last command'']',
- \])
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \ + [
+ \ '',
+ \ '(finished - exit code 0) ''first command''',
+ \ '(finished - exit code 1) [''/bin/bash'', ''\c'', ''last command'']',
+ \ ]
+ \)
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo command history should print command output if logging is on):
@@ -421,31 +505,36 @@ Execute (ALEInfo command history should print command output if logging is on):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
- call CheckInfo([
+ call CheckInfo(
+ \ [
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header + [
- \ '',
- \ '(finished - exit code 0) ''first command''',
- \ '',
- \ '<<<OUTPUT STARTS>>>',
- \ 'some',
- \ 'first command output',
- \ '<<<OUTPUT ENDS>>>',
- \ '',
- \ '(finished - exit code 1) [''/bin/bash'', ''\c'', ''last command'']',
- \ '',
- \ '<<<OUTPUT STARTS>>>',
- \ 'different second command output',
- \ '<<<OUTPUT ENDS>>>',
- \ '',
- \ '(finished - exit code 0) ''command with no output''',
- \ '',
- \ '<<<NO OUTPUT RETURNED>>>',
- \])
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \ + [
+ \ '',
+ \ '(finished - exit code 0) ''first command''',
+ \ '',
+ \ '<<<OUTPUT STARTS>>>',
+ \ 'some',
+ \ 'first command output',
+ \ '<<<OUTPUT ENDS>>>',
+ \ '',
+ \ '(finished - exit code 1) [''/bin/bash'', ''\c'', ''last command'']',
+ \ '',
+ \ '<<<OUTPUT STARTS>>>',
+ \ 'different second command output',
+ \ '<<<OUTPUT ENDS>>>',
+ \ '',
+ \ '(finished - exit code 0) ''command with no output''',
+ \ '',
+ \ '<<<NO OUTPUT RETURNED>>>',
+ \ ]
+ \)
Execute (ALEInfo should include executable checks in the history):
call ale#linter#Define('testft', g:testlinter1)
@@ -454,18 +543,23 @@ Execute (ALEInfo should include executable checks in the history):
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
- call CheckInfo([
+ call CheckInfo(
+ \ [
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header + [
- \ '',
- \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
- \ '(executable check - failure) TheresNoWayThisIsExecutable',
- \ '(executable check - failure) TheresNoWayThisIsExecutable',
- \])
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \ + [
+ \ '',
+ \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
+ \ '(executable check - failure) TheresNoWayThisIsExecutable',
+ \ '(executable check - failure) TheresNoWayThisIsExecutable',
+ \ ]
+ \)
Execute (The option for caching failing executable checks should work):
let g:ale_cache_executable_check_failures = 1
@@ -478,17 +572,22 @@ Execute (The option for caching failing executable checks should work):
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
- call CheckInfo([
+ call CheckInfo(
+ \ [
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
- \ ' Linter Variables:',
- \ '',
- \] + g:globals_lines + g:command_header + [
- \ '',
- \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
- \ '(executable check - failure) TheresNoWayThisIsExecutable',
- \])
+ \ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
+ \ + g:globals_lines
+ \ + g:command_header
+ \ + [
+ \ '',
+ \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
+ \ '(executable check - failure) TheresNoWayThisIsExecutable',
+ \ ]
+ \)
Given testft (Empty buffer):
Execute (LSP errors for a linter should be outputted):
@@ -500,9 +599,9 @@ Execute (LSP errors for a linter should be outputted):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
- \ ' Linter Variables:',
- \ '',
\ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
\ + g:globals_lines
\ + [
\ ' LSP Error Messages:',
@@ -524,9 +623,9 @@ Execute (LSP errors for other linters shouldn't appear):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
- \ ' Linter Variables:',
- \ '',
\ ]
+ \ + g:fixer_lines
+ \ + g:variables_lines
\ + g:globals_lines
\ + g:command_header
\)