2017-05-18 12:21:14 +00:00
|
|
|
Before:
|
2017-05-30 20:32:51 +00:00
|
|
|
Save g:ale_fixers
|
|
|
|
Save &shell
|
|
|
|
Save g:ale_enabled
|
|
|
|
Save g:ale_fix_on_save
|
|
|
|
Save g:ale_lint_on_save
|
|
|
|
Save g:ale_echo_cursor
|
2020-08-16 20:19:07 +00:00
|
|
|
Save g:ale_command_wrapper
|
2020-08-23 18:55:42 +00:00
|
|
|
Save g:ale_filename_mappings
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2017-11-22 14:55:08 +00:00
|
|
|
silent! cd /testplugin/test/fix
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2019-05-13 12:44:29 +00:00
|
|
|
unlet! b:ale_lint_on_save
|
2017-05-19 14:24:21 +00:00
|
|
|
let g:ale_enabled = 0
|
2017-05-30 20:32:51 +00:00
|
|
|
let g:ale_echo_cursor = 0
|
2020-08-16 20:19:07 +00:00
|
|
|
let g:ale_command_wrapper = ''
|
2017-05-18 12:21:14 +00:00
|
|
|
let g:ale_run_synchronously = 1
|
2017-10-23 22:09:40 +00:00
|
|
|
let g:ale_set_lists_synchronously = 1
|
2017-05-30 21:15:24 +00:00
|
|
|
let g:ale_fix_buffer_data = {}
|
2017-05-18 12:21:14 +00:00
|
|
|
let g:ale_fixers = {
|
|
|
|
\ 'testft': [],
|
|
|
|
\}
|
2020-08-23 18:55:42 +00:00
|
|
|
let g:ale_filename_mappings = {}
|
2017-10-23 22:09:40 +00:00
|
|
|
|
2017-12-23 13:13:55 +00:00
|
|
|
let g:pre_success = 0
|
|
|
|
let g:post_success = 0
|
|
|
|
augroup VaderTest
|
|
|
|
autocmd!
|
|
|
|
autocmd User ALEFixPre let g:pre_success = 1
|
|
|
|
autocmd User ALEFixPost let g:post_success = 1
|
2018-10-29 18:28:28 +00:00
|
|
|
augroup END
|
2017-12-23 13:13:55 +00:00
|
|
|
|
2017-10-23 22:09:40 +00:00
|
|
|
if !has('win32')
|
|
|
|
let &shell = '/bin/bash'
|
|
|
|
endif
|
|
|
|
|
|
|
|
call ale#test#SetDirectory('/testplugin/test')
|
|
|
|
call ale#test#SetFilename('test.txt')
|
2018-07-16 23:18:20 +00:00
|
|
|
call ale#linter#PreventLoading('testft')
|
2017-05-18 12:21:14 +00:00
|
|
|
|
2019-02-22 20:48:06 +00:00
|
|
|
function AddCarets(buffer, lines) abort
|
2017-05-18 12:21:14 +00:00
|
|
|
" map() is applied to the original lines here.
|
|
|
|
" This way, we can ensure that defensive copies are made.
|
|
|
|
return map(a:lines, '''^'' . v:val')
|
|
|
|
endfunction
|
|
|
|
|
2019-09-20 18:02:21 +00:00
|
|
|
function Capitalize(buffer, lines) abort
|
|
|
|
return map(a:lines, 'toupper(v:val)')
|
2017-05-18 12:21:14 +00:00
|
|
|
endfunction
|
|
|
|
|
2019-02-22 20:48:06 +00:00
|
|
|
function DoNothing(buffer, lines) abort
|
2017-05-18 12:21:14 +00:00
|
|
|
return 0
|
|
|
|
endfunction
|
|
|
|
|
2019-02-22 20:48:06 +00:00
|
|
|
function CatLine(buffer, lines) abort
|
2017-05-18 12:21:14 +00:00
|
|
|
return {'command': 'cat - <(echo d)'}
|
|
|
|
endfunction
|
|
|
|
|
2017-06-06 22:13:53 +00:00
|
|
|
function CatLineOneArg(buffer) abort
|
|
|
|
return {'command': 'cat - <(echo d)'}
|
|
|
|
endfunction
|
|
|
|
|
2019-02-26 16:56:16 +00:00
|
|
|
function CatLineDeferred(buffer, lines) abort
|
|
|
|
return ale#command#Run(a:buffer, 'echo', {
|
|
|
|
\ -> ale#command#Run(a:buffer, 'echo', {-> {'command': 'cat - <(echo d)'}})
|
|
|
|
\})
|
|
|
|
endfunction
|
|
|
|
|
2019-02-22 20:48:06 +00:00
|
|
|
function ReplaceWithTempFile(buffer, lines) abort
|
2017-05-18 12:21:14 +00:00
|
|
|
return {'command': 'echo x > %t', 'read_temporary_file': 1}
|
|
|
|
endfunction
|
|
|
|
|
2019-02-22 20:48:06 +00:00
|
|
|
function CatWithTempFile(buffer, lines) abort
|
2019-02-06 22:00:11 +00:00
|
|
|
return {'command': 'cat %t <(echo d)'}
|
|
|
|
endfunction
|
|
|
|
|
2020-08-23 18:55:42 +00:00
|
|
|
function EchoFilename(buffer, lines) abort
|
|
|
|
return {'command': 'echo %s'}
|
|
|
|
endfunction
|
|
|
|
|
2019-02-22 20:48:06 +00:00
|
|
|
function RemoveLastLine(buffer, lines) abort
|
2017-05-19 08:53:28 +00:00
|
|
|
return ['a', 'b']
|
|
|
|
endfunction
|
2017-05-19 14:24:21 +00:00
|
|
|
|
2017-06-06 22:13:53 +00:00
|
|
|
function RemoveLastLineOneArg(buffer) abort
|
|
|
|
return ['a', 'b']
|
|
|
|
endfunction
|
|
|
|
|
2017-05-30 20:32:51 +00:00
|
|
|
function! TestCallback(buffer, output)
|
|
|
|
return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
|
|
|
|
endfunction
|
|
|
|
|
2022-10-29 11:56:09 +00:00
|
|
|
" echo will output a single blank line, and we should ignore it.
|
2019-02-22 20:48:06 +00:00
|
|
|
function! IgnoredEmptyOutput(buffer, output)
|
2017-11-22 12:41:16 +00:00
|
|
|
return {'command': has('win32') ? 'echo(' : 'echo'}
|
2017-11-22 12:01:21 +00:00
|
|
|
endfunction
|
|
|
|
|
2019-02-22 20:48:06 +00:00
|
|
|
function! EchoLineNoPipe(buffer, output)
|
2017-11-22 13:01:13 +00:00
|
|
|
return {'command': 'echo new line', 'read_buffer': 0}
|
|
|
|
endfunction
|
|
|
|
|
2017-05-30 20:32:51 +00:00
|
|
|
function! SetUpLinters()
|
|
|
|
call ale#linter#Define('testft', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'TestCallback',
|
|
|
|
\ 'executable': 'true',
|
|
|
|
\ 'command': 'true',
|
|
|
|
\})
|
|
|
|
endfunction
|
|
|
|
|
2017-11-07 19:47:20 +00:00
|
|
|
function GetLastMessage()
|
|
|
|
redir => l:output
|
|
|
|
silent mess
|
|
|
|
redir END
|
|
|
|
|
|
|
|
let l:lines = split(l:output, "\n")
|
|
|
|
|
|
|
|
return empty(l:lines) ? '' : l:lines[-1]
|
|
|
|
endfunction
|
|
|
|
|
2017-11-22 22:32:53 +00:00
|
|
|
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
|
|
|
|
|
2017-11-22 23:45:51 +00:00
|
|
|
" Escaping needs to be handled specially for CMD on Windows.
|
|
|
|
let l:json_string = has('win32')
|
|
|
|
\ ? '{"output":["x","y","z"]}'
|
|
|
|
\ : ale#Escape('{"output": ["x", "y", "z"]}')
|
|
|
|
|
2017-11-22 22:32:53 +00:00
|
|
|
return {
|
2017-11-22 23:45:51 +00:00
|
|
|
\ 'command': 'echo ' . l:json_string,
|
2017-11-22 22:32:53 +00:00
|
|
|
\ 'read_buffer': 0,
|
|
|
|
\ 'process_with': l:ProcessWith,
|
|
|
|
\}
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! JSONPostProcessor(buffer, output) abort
|
2017-11-22 23:45:51 +00:00
|
|
|
return json_decode(a:output[0]).output
|
2017-11-22 22:32:53 +00:00
|
|
|
endfunction
|
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
After:
|
|
|
|
Restore
|
2019-02-26 08:35:58 +00:00
|
|
|
unlet! g:test_filename
|
2017-05-18 12:21:14 +00:00
|
|
|
unlet! g:ale_run_synchronously
|
2017-10-23 22:09:40 +00:00
|
|
|
unlet! g:ale_set_lists_synchronously
|
2019-02-06 22:00:11 +00:00
|
|
|
unlet! g:ale_run_synchronously_callbacks
|
2017-05-18 12:21:14 +00:00
|
|
|
unlet! g:ale_emulate_job_failure
|
2017-05-20 15:00:05 +00:00
|
|
|
unlet! b:ale_fixers
|
2019-05-13 12:44:29 +00:00
|
|
|
unlet! b:ale_lint_on_save
|
2017-10-30 22:19:57 +00:00
|
|
|
unlet! b:ale_fix_on_save
|
2018-11-10 10:06:48 +00:00
|
|
|
unlet! b:ale_quitting
|
2017-05-18 12:21:14 +00:00
|
|
|
delfunction AddCarets
|
2019-09-20 18:02:21 +00:00
|
|
|
delfunction Capitalize
|
2017-05-18 12:21:14 +00:00
|
|
|
delfunction DoNothing
|
|
|
|
delfunction CatLine
|
2017-06-06 22:13:53 +00:00
|
|
|
delfunction CatLineOneArg
|
2019-02-26 16:56:16 +00:00
|
|
|
delfunction CatLineDeferred
|
2017-05-18 12:21:14 +00:00
|
|
|
delfunction ReplaceWithTempFile
|
2019-02-06 22:00:11 +00:00
|
|
|
delfunction CatWithTempFile
|
2020-08-23 18:55:42 +00:00
|
|
|
delfunction EchoFilename
|
2017-05-19 08:53:28 +00:00
|
|
|
delfunction RemoveLastLine
|
2017-06-06 22:13:53 +00:00
|
|
|
delfunction RemoveLastLineOneArg
|
2017-05-30 20:32:51 +00:00
|
|
|
delfunction TestCallback
|
|
|
|
delfunction SetUpLinters
|
2017-11-07 19:47:20 +00:00
|
|
|
delfunction GetLastMessage
|
2017-11-22 12:01:21 +00:00
|
|
|
delfunction IgnoredEmptyOutput
|
2017-11-22 13:01:13 +00:00
|
|
|
delfunction EchoLineNoPipe
|
2017-11-22 22:32:53 +00:00
|
|
|
delfunction FixWithJSONPostProcessing
|
|
|
|
delfunction JSONPostProcessor
|
2017-10-23 22:09:40 +00:00
|
|
|
|
2018-10-29 18:28:28 +00:00
|
|
|
augroup VaderTest
|
|
|
|
autocmd!
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
augroup! VaderTest
|
|
|
|
|
2017-10-23 22:09:40 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
|
2017-05-18 22:50:06 +00:00
|
|
|
call ale#fix#registry#ResetToDefaults()
|
2017-05-30 20:32:51 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
2017-08-05 18:51:38 +00:00
|
|
|
setlocal buftype=nofile
|
|
|
|
|
2019-02-26 08:35:58 +00:00
|
|
|
if exists('g:test_filename') && filereadable(g:test_filename)
|
|
|
|
call delete(g:test_filename)
|
2017-05-30 20:32:51 +00:00
|
|
|
endif
|
2017-05-18 12:21:14 +00:00
|
|
|
|
2017-07-10 12:40:22 +00:00
|
|
|
call setloclist(0, [])
|
|
|
|
|
2017-05-30 21:15:24 +00:00
|
|
|
let g:ale_fix_buffer_data = {}
|
|
|
|
|
2017-11-07 19:47:20 +00:00
|
|
|
" Clear the messages between tests.
|
|
|
|
echomsg ''
|
|
|
|
|
2020-09-08 20:40:10 +00:00
|
|
|
if !exists('g:ale_command_wrapper')
|
|
|
|
let g:ale_command_wrapper = ''
|
|
|
|
endif
|
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
Given testft (A file with three lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
Execute(ALEFix should complain when there are no functions to call):
|
2017-11-07 19:47:20 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-11-07 19:47:20 +00:00
|
|
|
AssertEqual 'No fixers have been defined. Try :ALEFixSuggest', GetLastMessage()
|
2017-05-18 12:21:14 +00:00
|
|
|
|
2020-09-08 20:40:10 +00:00
|
|
|
Execute(ALEFix should not complain when the command is run with a bang):
|
|
|
|
echom 'none'
|
|
|
|
|
|
|
|
ALEFix!
|
|
|
|
call ale#test#FlushJobs()
|
|
|
|
AssertEqual 'none', GetLastMessage()
|
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
Execute(ALEFix should apply simple functions):
|
|
|
|
let g:ale_fixers.testft = ['AddCarets']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Expect(The first function should be used):
|
|
|
|
^a
|
|
|
|
^b
|
|
|
|
^c
|
|
|
|
|
2020-08-23 18:55:42 +00:00
|
|
|
Execute(Should apply filename mpapings):
|
|
|
|
" The command echos %s, and we'll map the current path so we can check
|
|
|
|
" that ALEFix applies filename mappings, end-to-end.
|
|
|
|
let g:ale_filename_mappings = {
|
|
|
|
\ 'echo_filename': [
|
2020-08-23 19:05:09 +00:00
|
|
|
\ [expand('%:p:h') . '/', '/some/fake/path/'],
|
2020-08-23 18:55:42 +00:00
|
|
|
\ ],
|
|
|
|
\}
|
|
|
|
|
|
|
|
call ale#fix#registry#Add('echo_filename', 'EchoFilename', [], 'echo filename')
|
|
|
|
let g:ale_fixers.testft = ['echo_filename']
|
|
|
|
ALEFix
|
|
|
|
call ale#test#FlushJobs()
|
2020-08-23 19:19:22 +00:00
|
|
|
" Remote trailing whitespace from the line.
|
|
|
|
call setline(1, substitute(getline(1), '[ \r]\+$', '', ''))
|
2020-08-23 19:14:08 +00:00
|
|
|
|
2020-08-23 18:55:42 +00:00
|
|
|
Expect(The mapped filename should be printed):
|
|
|
|
/some/fake/path/test.txt
|
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
Execute(ALEFix should apply simple functions in a chain):
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['AddCarets', 'Capitalize']
|
2017-05-18 12:21:14 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Expect(Both functions should be used):
|
2019-09-20 18:02:21 +00:00
|
|
|
^A
|
|
|
|
^B
|
|
|
|
^C
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should allow 0 to be returned to skip functions):
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['DoNothing', 'Capitalize']
|
2017-05-18 12:21:14 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Expect(Only the second function should be applied):
|
2019-09-20 18:02:21 +00:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
2017-05-18 12:21:14 +00:00
|
|
|
|
2018-06-21 00:21:11 +00:00
|
|
|
Execute(The * fixers shouldn't be used if an empty list is set for fixers):
|
|
|
|
let g:ale_fixers.testft = []
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers['*'] = ['Capitalize']
|
2018-06-21 00:21:11 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2018-06-21 00:21:11 +00:00
|
|
|
|
|
|
|
Expect(Nothing should be changed):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
Execute(* fixers should be used if no filetype is matched):
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers = {'*': ['Capitalize']}
|
2018-06-21 00:21:11 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2018-06-21 00:21:11 +00:00
|
|
|
|
|
|
|
Expect(The file should be changed):
|
2019-09-20 18:02:21 +00:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
2018-06-21 00:21:11 +00:00
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
Execute(ALEFix should allow commands to be run):
|
2017-10-23 22:09:40 +00:00
|
|
|
if has('win32')
|
|
|
|
" Just skip this test on Windows, we can't run it.
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
else
|
|
|
|
let g:ale_fixers.testft = ['CatLine']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Expect(An extra line should be added):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
|
|
|
|
2018-04-17 23:10:51 +00:00
|
|
|
Execute(ALEFix should use fixers passed in commandline when provided):
|
|
|
|
let g:ale_fixers.testft = ['RemoveLastLine']
|
2019-09-20 18:02:21 +00:00
|
|
|
ALEFix AddCarets Capitalize
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2018-04-17 23:10:51 +00:00
|
|
|
|
|
|
|
Expect(Only fixers passed via command line should be run):
|
2019-09-20 18:02:21 +00:00
|
|
|
^A
|
|
|
|
^B
|
|
|
|
^C
|
2018-04-17 23:10:51 +00:00
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
Execute(ALEFix should allow temporary files to be read):
|
2017-10-23 22:09:40 +00:00
|
|
|
if has('win32')
|
|
|
|
" Just skip this test on Windows, we can't run it.
|
|
|
|
call setline(1, ['x'])
|
|
|
|
2,3d
|
|
|
|
else
|
|
|
|
let g:ale_fixers.testft = ['ReplaceWithTempFile']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Expect(The line we wrote to the temporary file should be used here):
|
|
|
|
x
|
|
|
|
|
2019-02-06 22:00:11 +00:00
|
|
|
Execute(ALEFix should not read the temporary file when the option is not set):
|
|
|
|
if has('win32')
|
|
|
|
" Just skip this test on Windows, we can't run it.
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
else
|
|
|
|
let g:ale_fixers.testft = ['CatWithTempFile']
|
|
|
|
ALEFix
|
|
|
|
call ale#test#FlushJobs()
|
|
|
|
endif
|
|
|
|
|
|
|
|
Expect(An extra line should be added):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
Execute(ALEFix should allow jobs and simple functions to be combined):
|
2017-10-23 22:09:40 +00:00
|
|
|
if has('win32')
|
|
|
|
" Just skip this test on Windows, we can't run it.
|
2019-09-20 18:02:21 +00:00
|
|
|
call setline(1, ['X'])
|
2017-10-23 22:09:40 +00:00
|
|
|
2,3d
|
|
|
|
else
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['ReplaceWithTempFile', 'Capitalize']
|
2017-10-23 22:09:40 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Expect(The lines from the temporary file should be modified):
|
2019-09-20 18:02:21 +00:00
|
|
|
X
|
2017-05-18 12:21:14 +00:00
|
|
|
|
2017-05-18 16:50:20 +00:00
|
|
|
Execute(ALEFix should send lines modified by functions to jobs):
|
2017-10-23 22:09:40 +00:00
|
|
|
if has('win32')
|
|
|
|
" Just skip this test on Windows, we can't run it.
|
2019-09-20 18:02:21 +00:00
|
|
|
call setline(1, ['A', 'B', 'C', 'd'])
|
2017-10-23 22:09:40 +00:00
|
|
|
else
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['Capitalize', 'CatLine']
|
2017-10-23 22:09:40 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-05-18 16:50:20 +00:00
|
|
|
|
|
|
|
Expect(The lines should first be modified by the function, then the job):
|
2019-09-20 18:02:21 +00:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
2017-05-18 16:50:20 +00:00
|
|
|
d
|
|
|
|
|
2017-05-18 12:21:14 +00:00
|
|
|
Execute(ALEFix should skip commands when jobs fail to run):
|
|
|
|
let g:ale_emulate_job_failure = 1
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['CatLine', 'Capitalize']
|
2017-05-18 12:21:14 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-18 12:21:14 +00:00
|
|
|
|
|
|
|
Expect(Only the second function should be applied):
|
2019-09-20 18:02:21 +00:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
2017-05-18 16:26:17 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should handle strings for selecting a single function):
|
|
|
|
let g:ale_fixers.testft = 'AddCarets'
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-18 16:26:17 +00:00
|
|
|
|
|
|
|
Expect(The first function should be used):
|
|
|
|
^a
|
|
|
|
^b
|
|
|
|
^c
|
2017-05-18 22:50:06 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should use functions from the registry):
|
|
|
|
call ale#fix#registry#Add('add_carets', 'AddCarets', [], 'Add some carets')
|
|
|
|
let g:ale_fixers.testft = ['add_carets']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-18 22:50:06 +00:00
|
|
|
|
|
|
|
Expect(The registry function should be used):
|
|
|
|
^a
|
|
|
|
^b
|
|
|
|
^c
|
2017-05-19 08:53:28 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should be able to remove the last line for files):
|
|
|
|
let g:ale_fixers.testft = ['RemoveLastLine']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-19 08:53:28 +00:00
|
|
|
|
|
|
|
Expect(There should be only two lines):
|
|
|
|
a
|
|
|
|
b
|
2017-05-19 14:44:52 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should accept funcrefs):
|
|
|
|
let g:ale_fixers.testft = [function('RemoveLastLine')]
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-19 14:44:52 +00:00
|
|
|
|
|
|
|
Expect(There should be only two lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
|
|
|
|
Execute(ALEFix should accept lambdas):
|
|
|
|
if has('nvim')
|
|
|
|
" NeoVim 0.1.7 can't interpret lambdas correctly, so just set the lines
|
|
|
|
" to make the test pass.
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
else
|
2019-02-22 20:48:06 +00:00
|
|
|
let g:ale_fixers.testft = [{buffer, lines -> lines + ['d']}]
|
2017-05-19 14:44:52 +00:00
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-19 14:44:52 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
Expect(There should be an extra line):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
2017-05-20 15:00:05 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should user buffer-local fixer settings):
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['AddCarets', 'Capitalize']
|
2017-05-20 15:00:05 +00:00
|
|
|
let b:ale_fixers = {'testft': ['RemoveLastLine']}
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-20 15:00:05 +00:00
|
|
|
|
|
|
|
Expect(There should be only two lines):
|
|
|
|
a
|
|
|
|
b
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2017-11-11 23:04:08 +00:00
|
|
|
Execute(ALEFix should allow Lists to be used for buffer-local fixer settings):
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['AddCarets', 'Capitalize']
|
2017-11-11 23:04:08 +00:00
|
|
|
let b:ale_fixers = ['RemoveLastLine']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-11-11 23:04:08 +00:00
|
|
|
|
|
|
|
Expect(There should be only two lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
|
2017-05-30 20:32:51 +00:00
|
|
|
Given testft (A file with three lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
2018-11-10 10:06:48 +00:00
|
|
|
Execute(ALEFix should fix files on the save event):
|
2017-05-30 20:32:51 +00:00
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
|
2019-02-26 08:35:58 +00:00
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
|
|
|
call writefile(getline(1, '$'), g:test_filename)
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['Capitalize']
|
2019-06-04 20:51:44 +00:00
|
|
|
|
|
|
|
" We have to set the buftype to empty so the file will be written.
|
|
|
|
setlocal buftype=
|
|
|
|
|
|
|
|
call SetUpLinters()
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
|
|
|
call ale#test#FlushJobs()
|
|
|
|
|
|
|
|
" We should save the file.
|
2019-09-20 18:02:21 +00:00
|
|
|
AssertEqual ['A', 'B', 'C'], readfile(g:test_filename)
|
2019-06-04 20:51:44 +00:00
|
|
|
Assert !&modified, 'The file was marked as ''modified'''
|
|
|
|
|
|
|
|
if !has('win32')
|
|
|
|
" We should have run the linter.
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'text': 'xxx',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
2022-04-01 12:17:15 +00:00
|
|
|
\}], ale#test#GetLoclistWithoutNewerKeys()
|
2019-06-04 20:51:44 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
Expect(The buffer should be modified):
|
2019-09-20 18:02:21 +00:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
2019-06-04 20:51:44 +00:00
|
|
|
|
|
|
|
Given testft (A file with three lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
Execute(ALEFix should run the linters with b:ale_lint_on_save = 1):
|
|
|
|
let g:ale_fix_on_save = 0
|
|
|
|
let b:ale_fix_on_save = 1
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
|
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
|
|
|
call writefile(getline(1, '$'), g:test_filename)
|
|
|
|
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['Capitalize']
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2017-08-05 18:51:38 +00:00
|
|
|
" We have to set the buftype to empty so the file will be written.
|
|
|
|
setlocal buftype=
|
|
|
|
|
2017-05-30 20:32:51 +00:00
|
|
|
call SetUpLinters()
|
2017-07-31 23:03:24 +00:00
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-30 20:32:51 +00:00
|
|
|
|
|
|
|
" We should save the file.
|
2019-09-20 18:02:21 +00:00
|
|
|
AssertEqual ['A', 'B', 'C'], readfile(g:test_filename)
|
2019-02-26 08:35:58 +00:00
|
|
|
Assert !&modified, 'The file was marked as ''modified'''
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2017-10-23 22:09:40 +00:00
|
|
|
if !has('win32')
|
|
|
|
" We should have run the linter.
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'text': 'xxx',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
2022-04-01 12:17:15 +00:00
|
|
|
\}], ale#test#GetLoclistWithoutNewerKeys()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-05-30 20:32:51 +00:00
|
|
|
|
|
|
|
Expect(The buffer should be modified):
|
2019-09-20 18:02:21 +00:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2018-11-10 10:06:48 +00:00
|
|
|
Execute(ALEFix should not fix files on :wq):
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
|
2019-02-26 08:35:58 +00:00
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
|
|
|
call writefile(getline(1, '$'), g:test_filename)
|
2018-11-10 10:06:48 +00:00
|
|
|
|
2019-09-20 18:02:21 +00:00
|
|
|
let g:ale_fixers.testft = ['Capitalize']
|
2018-11-10 10:06:48 +00:00
|
|
|
|
|
|
|
" We have to set the buftype to empty so the file will be written.
|
|
|
|
setlocal buftype=
|
|
|
|
|
|
|
|
call ale#events#QuitEvent(bufnr(''))
|
|
|
|
|
|
|
|
call SetUpLinters()
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
|
|
|
|
|
|
|
" We should save the file.
|
2019-02-26 08:35:58 +00:00
|
|
|
AssertEqual ['a', 'b', 'c'], readfile(g:test_filename)
|
2018-11-10 10:06:48 +00:00
|
|
|
Assert &modified, 'The was not marked as ''modified'''
|
|
|
|
|
|
|
|
" We should not run the linter.
|
2022-04-01 12:17:15 +00:00
|
|
|
AssertEqual [], ale#test#GetLoclistWithoutNewerKeys()
|
2018-11-10 10:06:48 +00:00
|
|
|
|
|
|
|
Expect(The buffer should not be modified):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
2017-05-30 20:32:51 +00:00
|
|
|
Given testft (A file with three lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
Execute(ALEFix should still lint with no linters to be applied):
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
|
2019-02-26 08:35:58 +00:00
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
2017-05-30 20:32:51 +00:00
|
|
|
|
|
|
|
let g:ale_fixers.testft = []
|
|
|
|
|
|
|
|
call SetUpLinters()
|
2017-07-31 23:03:24 +00:00
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2019-02-26 08:35:58 +00:00
|
|
|
Assert !filereadable(g:test_filename), 'The file should not have been saved'
|
2017-05-30 20:32:51 +00:00
|
|
|
|
2017-10-23 22:09:40 +00:00
|
|
|
if !has('win32')
|
|
|
|
" We have run the linter.
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'text': 'xxx',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
2022-04-01 12:17:15 +00:00
|
|
|
\}], ale#test#GetLoclistWithoutNewerKeys()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-07-10 12:40:22 +00:00
|
|
|
|
|
|
|
Expect(The buffer should be the same):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
Execute(ALEFix should still lint when nothing was fixed on save):
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
|
2019-02-26 08:35:58 +00:00
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
2017-07-10 12:40:22 +00:00
|
|
|
|
|
|
|
let g:ale_fixers.testft = ['DoNothing']
|
|
|
|
|
|
|
|
call SetUpLinters()
|
2017-07-31 23:03:24 +00:00
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-07-10 12:40:22 +00:00
|
|
|
|
2019-02-26 08:35:58 +00:00
|
|
|
Assert !filereadable(g:test_filename), 'The file should not have been saved'
|
2017-07-10 12:40:22 +00:00
|
|
|
|
2017-10-23 22:09:40 +00:00
|
|
|
if !has('win32')
|
|
|
|
" We should have run the linter.
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'text': 'xxx',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
2022-04-01 12:17:15 +00:00
|
|
|
\}], ale#test#GetLoclistWithoutNewerKeys()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-05-30 20:32:51 +00:00
|
|
|
|
|
|
|
Expect(The buffer should be the same):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
2017-05-30 21:15:24 +00:00
|
|
|
|
2019-05-13 12:44:29 +00:00
|
|
|
Execute(ALEFix should not lint the buffer on save if linting on save is disabled globally):
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let g:ale_lint_on_save = 0
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
|
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
|
|
|
|
|
|
|
let g:ale_fixers.testft = ['DoNothing']
|
|
|
|
|
|
|
|
call SetUpLinters()
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
|
|
|
call ale#test#FlushJobs()
|
|
|
|
|
|
|
|
Assert !filereadable(g:test_filename), 'The file should not have been saved'
|
|
|
|
|
2022-04-01 12:17:15 +00:00
|
|
|
AssertEqual [], ale#test#GetLoclistWithoutNewerKeys()
|
2019-05-13 12:44:29 +00:00
|
|
|
|
|
|
|
Expect(The buffer should be the same):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
Execute(ALEFix should not lint the buffer on save if linting on save is disabled locally):
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let b:ale_lint_on_save = 0
|
|
|
|
let g:ale_enabled = 1
|
|
|
|
|
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
|
|
|
|
|
|
|
let g:ale_fixers.testft = ['DoNothing']
|
|
|
|
|
|
|
|
call SetUpLinters()
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
|
|
|
call ale#test#FlushJobs()
|
|
|
|
|
|
|
|
Assert !filereadable(g:test_filename), 'The file should not have been saved'
|
|
|
|
|
2022-04-01 12:17:15 +00:00
|
|
|
AssertEqual [], ale#test#GetLoclistWithoutNewerKeys()
|
2019-05-13 12:44:29 +00:00
|
|
|
|
|
|
|
Expect(The buffer should be the same):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
2017-05-30 21:15:24 +00:00
|
|
|
Given testft (A file with three lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
Execute(ale#fix#InitBufferData() should set up the correct data):
|
2019-02-26 08:35:58 +00:00
|
|
|
let g:test_filename = tempname()
|
|
|
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
2017-05-30 21:15:24 +00:00
|
|
|
|
|
|
|
call ale#fix#InitBufferData(bufnr(''), 'save_file')
|
|
|
|
|
|
|
|
AssertEqual {
|
|
|
|
\ bufnr(''): {
|
|
|
|
\ 'temporary_directory_list': [],
|
|
|
|
\ 'done': 0,
|
|
|
|
\ 'lines_before': ['a', 'b', 'c'],
|
|
|
|
\ 'should_save': 1,
|
2020-09-08 20:40:10 +00:00
|
|
|
\ 'ignore_file_changed_errors': 0,
|
|
|
|
\ },
|
|
|
|
\}, g:ale_fix_buffer_data
|
|
|
|
|
|
|
|
call ale#fix#InitBufferData(bufnr(''), '!')
|
|
|
|
|
|
|
|
AssertEqual {
|
|
|
|
\ bufnr(''): {
|
|
|
|
\ 'temporary_directory_list': [],
|
|
|
|
\ 'done': 0,
|
|
|
|
\ 'lines_before': ['a', 'b', 'c'],
|
|
|
|
\ 'should_save': 0,
|
|
|
|
\ 'ignore_file_changed_errors': 1,
|
2017-05-30 21:15:24 +00:00
|
|
|
\ },
|
|
|
|
\}, g:ale_fix_buffer_data
|
2017-06-06 22:13:53 +00:00
|
|
|
|
|
|
|
Execute(ALEFix simple functions should be able to accept one argument, the buffer):
|
|
|
|
let g:ale_fixers.testft = ['RemoveLastLineOneArg']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-06-06 22:13:53 +00:00
|
|
|
|
|
|
|
Expect(There should be only two lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
|
2020-08-29 11:35:40 +00:00
|
|
|
Execute(ALEFix should modify a buffer that is not modifiable, if it becomes modifiable later):
|
2020-08-29 11:33:17 +00:00
|
|
|
let g:ale_fixers.testft = ['RemoveLastLineOneArg']
|
|
|
|
|
|
|
|
set nomodifiable
|
|
|
|
ALEFix
|
|
|
|
call ale#test#FlushJobs()
|
|
|
|
set modifiable
|
|
|
|
call ale#fix#ApplyQueuedFixes(bufnr(''))
|
|
|
|
|
|
|
|
Expect(There should be only two lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
|
2017-10-30 22:19:57 +00:00
|
|
|
Execute(b:ale_fix_on_save = 1 should override g:ale_fix_on_save = 0):
|
|
|
|
let g:ale_fix_on_save = 0
|
|
|
|
let b:ale_fix_on_save = 1
|
|
|
|
|
|
|
|
let g:ale_fixers.testft = ['RemoveLastLineOneArg']
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
|
|
|
|
|
|
|
Expect(There should be only two lines):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
|
|
|
|
Execute(b:ale_fix_on_save = 0 should override g:ale_fix_on_save = 1):
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let b:ale_fix_on_save = 0
|
|
|
|
|
|
|
|
let g:ale_fixers.testft = ['RemoveLastLineOneArg']
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
|
|
|
|
|
|
|
Expect(The lines should be the same):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
2017-06-06 22:13:53 +00:00
|
|
|
Execute(ALEFix functions returning jobs should be able to accept one argument):
|
2017-10-23 22:09:40 +00:00
|
|
|
if has('win32')
|
|
|
|
" Just skip this test on Windows, we can't run it.
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
else
|
|
|
|
let g:ale_fixers.testft = ['CatLine']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-23 22:09:40 +00:00
|
|
|
endif
|
2017-06-06 22:13:53 +00:00
|
|
|
|
|
|
|
Expect(An extra line should be added):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
2017-11-07 19:47:20 +00:00
|
|
|
|
|
|
|
Execute(ALE should print a message telling you something isn't a valid fixer when you type some nonsense):
|
|
|
|
let g:ale_fixers.testft = ['CatLine', 'invalidname']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-11-07 19:47:20 +00:00
|
|
|
|
|
|
|
AssertEqual 'There is no fixer named `invalidname`. Check :ALEFixSuggest', GetLastMessage()
|
2017-11-07 23:20:14 +00:00
|
|
|
|
2018-02-18 10:13:30 +00:00
|
|
|
Execute(ALE should complain about invalid fixers with minuses in the name):
|
|
|
|
let g:ale_fixers.testft = ['foo-bar']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2018-02-18 10:13:30 +00:00
|
|
|
|
|
|
|
AssertEqual 'There is no fixer named `foo-bar`. Check :ALEFixSuggest', GetLastMessage()
|
|
|
|
|
|
|
|
Execute(ALE should tolerate valid fixers with minuses in the name):
|
|
|
|
let g:ale_fixers.testft = ['prettier-standard']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2018-02-18 10:13:30 +00:00
|
|
|
|
2017-11-22 12:01:21 +00:00
|
|
|
Execute(Empty output should be ignored):
|
|
|
|
let g:ale_fixers.testft = ['IgnoredEmptyOutput']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-11-22 12:01:21 +00:00
|
|
|
|
|
|
|
Expect(The lines should be the same):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
2017-11-22 13:01:13 +00:00
|
|
|
|
|
|
|
Execute(A temporary file shouldn't be piped into the command when disabled):
|
|
|
|
let g:ale_fixers.testft = ['EchoLineNoPipe']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-11-22 13:01:13 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-12-20 12:20:38 +00:00
|
|
|
\ string(ale#job#PrepareCommand(bufnr(''), 'echo new line')),
|
2017-11-22 13:01:13 +00:00
|
|
|
\ string(ale#history#Get(bufnr(''))[-1].command)
|
|
|
|
|
2017-11-22 14:06:37 +00:00
|
|
|
" Remove trailing whitespace for Windows.
|
|
|
|
if has('win32')
|
|
|
|
%s/[[:space:]]*$//g
|
|
|
|
endif
|
|
|
|
|
2017-11-22 13:01:13 +00:00
|
|
|
Expect(The new line should be used):
|
|
|
|
new line
|
2017-11-22 22:32:53 +00:00
|
|
|
|
|
|
|
Execute(Post-processing should work):
|
|
|
|
let g:ale_fixers.testft = ['FixWithJSONPostProcessing']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
2017-11-22 22:32:53 +00:00
|
|
|
|
|
|
|
Expect(The lines in the JSON should be used):
|
|
|
|
x
|
|
|
|
y
|
|
|
|
z
|
2017-12-23 13:13:55 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should apply autocmds):
|
|
|
|
let g:ale_fixers.testft = ['AddCarets']
|
|
|
|
ALEFix
|
2019-02-06 22:00:11 +00:00
|
|
|
call ale#test#FlushJobs()
|
|
|
|
|
2017-12-23 13:13:55 +00:00
|
|
|
AssertEqual g:pre_success, 1
|
|
|
|
AssertEqual g:post_success, 1
|
2019-02-26 16:56:16 +00:00
|
|
|
|
|
|
|
Execute(ALEFix should support ale#command#Run):
|
2019-02-26 16:57:57 +00:00
|
|
|
if has('win32')
|
|
|
|
" Just skip this test on Windows, we can't run it.
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
else
|
|
|
|
let g:ale_fixers.testft = ['CatLineDeferred']
|
|
|
|
ALEFix
|
|
|
|
call ale#test#FlushJobs()
|
|
|
|
endif
|
2019-02-26 16:56:16 +00:00
|
|
|
|
|
|
|
Expect(The extra line should be added):
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|