2017-01-24 15:50:49 +00:00
|
|
|
Before:
|
|
|
|
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'}
|
|
|
|
let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout'}
|
|
|
|
|
|
|
|
call ale#linter#Reset()
|
|
|
|
let g:ale_linters = {}
|
|
|
|
let g:ale_linter_aliases = {}
|
2017-02-13 23:15:52 +00:00
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
let g:globals_string = join([
|
|
|
|
\ '',
|
|
|
|
\ ' Global Variables:',
|
|
|
|
\ '',
|
|
|
|
\ 'let g:ale_echo_cursor = 1',
|
|
|
|
\ 'let g:ale_echo_msg_error_str = ''Error''',
|
|
|
|
\ 'let g:ale_echo_msg_format = ''%s''',
|
|
|
|
\ 'let g:ale_echo_msg_warning_str = ''Warning''',
|
|
|
|
\ 'let g:ale_enabled = 1',
|
|
|
|
\ 'let g:ale_keep_list_window_open = 0',
|
|
|
|
\ 'let g:ale_lint_delay = 200',
|
|
|
|
\ 'let g:ale_lint_on_enter = 1',
|
2017-03-27 19:36:35 +00:00
|
|
|
\ 'let g:ale_lint_on_save = 1',
|
2017-03-30 22:21:37 +00:00
|
|
|
\ 'let g:ale_lint_on_text_changed = ''always''',
|
2017-02-13 23:15:52 +00:00
|
|
|
\ 'let g:ale_linter_aliases = {}',
|
|
|
|
\ 'let g:ale_linters = {}',
|
|
|
|
\ 'let g:ale_open_list = 0',
|
|
|
|
\ 'let g:ale_set_highlights = 1',
|
|
|
|
\ 'let g:ale_set_loclist = 1',
|
|
|
|
\ 'let g:ale_set_quickfix = 0',
|
|
|
|
\ 'let g:ale_set_signs = 1',
|
|
|
|
\ 'let g:ale_sign_column_always = 0',
|
|
|
|
\ 'let g:ale_sign_error = ''>>''',
|
|
|
|
\ 'let g:ale_sign_offset = 1000000',
|
|
|
|
\ 'let g:ale_sign_warning = ''--''',
|
|
|
|
\ 'let g:ale_statusline_format = [''%d error(s)'', ''%d warning(s)'', ''OK'']',
|
|
|
|
\ 'let g:ale_warn_about_trailing_whitespace = 1',
|
|
|
|
\], "\n")
|
2017-02-14 23:44:37 +00:00
|
|
|
let g:command_header = "\n Command History:\n"
|
2017-01-24 15:50:49 +00:00
|
|
|
|
|
|
|
After:
|
2017-04-26 23:07:41 +00:00
|
|
|
unlet! b:ale_linters
|
2017-01-24 15:50:49 +00:00
|
|
|
unlet! g:output
|
2017-02-13 23:15:52 +00:00
|
|
|
unlet! g:globals_string
|
2017-02-14 23:44:37 +00:00
|
|
|
unlet! g:command_header
|
|
|
|
let g:ale_buffer_info = {}
|
2017-02-16 23:18:57 +00:00
|
|
|
let g:ale_history_log_output = 0
|
2017-02-14 23:44:37 +00:00
|
|
|
unlet! g:ale_testft_testlinter1_foo
|
|
|
|
unlet! g:ale_testft_testlinter1_bar
|
|
|
|
unlet! g:ale_testft2_testlinter2_foo
|
2017-04-26 23:07:41 +00:00
|
|
|
unlet! b:ale_testft2_testlinter2_foo
|
2017-02-14 23:44:37 +00:00
|
|
|
unlet! g:ale_testft2_testlinter2_bar
|
2017-01-24 15:50:49 +00:00
|
|
|
|
|
|
|
Given nolintersft (Empty buffer with no linters):
|
|
|
|
Execute (ALEInfo with no linters should return the right output):
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: nolintersft\n
|
|
|
|
\Available Linters: []\n
|
2017-02-13 22:11:35 +00:00
|
|
|
\ Enabled Linters: []\n
|
|
|
|
\ Linter Variables:\n
|
2017-02-14 23:44:37 +00:00
|
|
|
\" . g:globals_string . g:command_header, g:output
|
2017-01-24 15:50:49 +00:00
|
|
|
|
2017-04-26 23:07:41 +00:00
|
|
|
Given (Empty buffer with no filetype):
|
|
|
|
Execute (ALEInfo should return buffer-local global ALE settings):
|
|
|
|
let b:ale_linters = {'x': ['y']}
|
|
|
|
let g:globals_string = substitute(
|
|
|
|
\ g:globals_string,
|
|
|
|
\ 'let g:ale_linters = {}',
|
|
|
|
\ "let g:ale_linters = {}\nlet b:ale_linters = {'x': ['y']}",
|
|
|
|
\ ''
|
|
|
|
\)
|
|
|
|
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: \n
|
|
|
|
\Available Linters: []\n
|
|
|
|
\ Enabled Linters: []\n
|
|
|
|
\ Linter Variables:\n
|
|
|
|
\" . g:globals_string . g:command_header, g:output
|
|
|
|
|
2017-01-24 15:50:49 +00:00
|
|
|
Given (Empty buffer with no filetype):
|
|
|
|
Execute (ALEInfo with no filetype should return the right output):
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: \n
|
|
|
|
\Available Linters: []\n
|
2017-02-13 22:11:35 +00:00
|
|
|
\ Enabled Linters: []\n
|
|
|
|
\ Linter Variables:\n
|
2017-02-14 23:44:37 +00:00
|
|
|
\" . g:globals_string . g:command_header, g:output
|
2017-01-24 15:50:49 +00:00
|
|
|
|
|
|
|
Given testft (Empty buffer):
|
|
|
|
Execute (ALEInfo with a single linter should return the right output):
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: testft\n
|
|
|
|
\Available Linters: ['testlinter1']\n
|
2017-02-13 22:11:35 +00:00
|
|
|
\ Enabled Linters: ['testlinter1']\n
|
|
|
|
\ Linter Variables:\n
|
2017-02-14 23:44:37 +00:00
|
|
|
\" . g:globals_string . g:command_header, g:output
|
2017-01-24 15:50:49 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: testft\n
|
|
|
|
\Available Linters: ['testlinter1', 'testlinter2']\n
|
2017-02-13 22:11:35 +00:00
|
|
|
\ Enabled Linters: ['testlinter1', 'testlinter2']\n
|
|
|
|
\ Linter Variables:\n
|
2017-02-14 23:44:37 +00:00
|
|
|
\" . g:globals_string . g:command_header, g:output
|
2017-01-24 15:50:49 +00:00
|
|
|
|
|
|
|
Given testft (Empty buffer):
|
|
|
|
Execute (ALEInfo should calculate enabled linters correctly):
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = { 'testft': ['testlinter2'] }
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: testft\n
|
|
|
|
\Available Linters: ['testlinter1', 'testlinter2']\n
|
2017-02-13 22:11:35 +00:00
|
|
|
\ Enabled Linters: ['testlinter2']\n
|
|
|
|
\ Linter Variables:\n
|
2017-02-13 23:15:52 +00:00
|
|
|
\",
|
|
|
|
\ "\n" . join(split(g:output, "\n")[:4], "\n")
|
2017-01-24 15:50:49 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: testft\n
|
|
|
|
\Available Linters: ['testlinter1']\n
|
2017-02-13 22:11:35 +00:00
|
|
|
\ Enabled Linters: ['testlinter1']\n
|
|
|
|
\ Linter Variables:\n
|
2017-02-14 23:44:37 +00:00
|
|
|
\" . g:globals_string . g:command_header, g:output
|
2017-01-24 15:50:49 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: testft.testft2\n
|
|
|
|
\Available Linters: ['testlinter1', 'testlinter2']\n
|
2017-02-13 22:11:35 +00:00
|
|
|
\ Enabled Linters: ['testlinter1', 'testlinter2']\n
|
|
|
|
\ Linter Variables:\n
|
2017-02-14 23:44:37 +00:00
|
|
|
\" . g:globals_string . g:command_header, g:output
|
2017-01-24 15:50:49 +00:00
|
|
|
|
2017-02-13 22:11:35 +00:00
|
|
|
Given testft.testft2 (Empty buffer with two filetypes):
|
|
|
|
Execute (ALEInfo should return appropriately named global variables):
|
|
|
|
let g:ale_testft_testlinter1_foo = 'abc'
|
|
|
|
let g:ale_testft_testlinter1_bar = ['abc']
|
|
|
|
let g:ale_testft2_testlinter2_foo = 123
|
|
|
|
let g:ale_testft2_testlinter2_bar = {'x': 'y'}
|
|
|
|
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: testft.testft2\n
|
|
|
|
\Available Linters: ['testlinter1', 'testlinter2']\n
|
|
|
|
\ Enabled Linters: ['testlinter1', 'testlinter2']\n
|
|
|
|
\ Linter Variables:\n
|
|
|
|
\\n
|
|
|
|
\let g:ale_testft2_testlinter2_bar = {'x': 'y'}\n
|
|
|
|
\let g:ale_testft2_testlinter2_foo = 123\n
|
|
|
|
\let g:ale_testft_testlinter1_bar = ['abc']\n
|
2017-02-14 23:44:37 +00:00
|
|
|
\let g:ale_testft_testlinter1_foo = 'abc'"
|
|
|
|
\ . g:globals_string . g:command_header, g:output
|
|
|
|
|
2017-04-26 23:07:41 +00:00
|
|
|
Given testft.testft2 (Empty buffer with two filetypes):
|
|
|
|
Execute (ALEInfo should buffer-local linter variables):
|
|
|
|
let g:ale_testft2_testlinter2_foo = 123
|
|
|
|
let b:ale_testft2_testlinter2_foo = 456
|
|
|
|
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual "\n
|
|
|
|
\ Current Filetype: testft.testft2\n
|
|
|
|
\Available Linters: ['testlinter1', 'testlinter2']\n
|
|
|
|
\ Enabled Linters: ['testlinter1', 'testlinter2']\n
|
|
|
|
\ Linter Variables:\n
|
|
|
|
\\n
|
|
|
|
\let g:ale_testft2_testlinter2_foo = 123\n
|
|
|
|
\let b:ale_testft2_testlinter2_foo = 456"
|
|
|
|
\ . g:globals_string . g:command_header, g:output
|
|
|
|
|
2017-02-14 23:44:37 +00:00
|
|
|
Given testft.testft2 (Empty buffer with two filetypes):
|
|
|
|
Execute (ALEInfo should return command history):
|
|
|
|
let g:ale_buffer_info[bufnr('%')] = {
|
|
|
|
\ 'history': [
|
2017-02-16 21:18:03 +00:00
|
|
|
\ {'status': 'started', 'job_id': 347, 'command': 'first command'},
|
|
|
|
\ {'status': 'started', 'job_id': 347, 'command': ['/bin/bash', '\c', 'last command']},
|
2017-02-14 23:44:37 +00:00
|
|
|
\ ],
|
|
|
|
\}
|
|
|
|
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual
|
|
|
|
\ join([
|
|
|
|
\ '',
|
|
|
|
\ ' Current Filetype: testft.testft2',
|
|
|
|
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
|
|
|
|
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
|
|
|
|
\ ' Linter Variables:',
|
|
|
|
\ g:globals_string . g:command_header,
|
2017-02-16 21:18:03 +00:00
|
|
|
\ '(started) ''first command''',
|
|
|
|
\ '(started) [''/bin/bash'', ''\c'', ''last command'']',
|
2017-02-14 23:44:37 +00:00
|
|
|
\ ], "\n"),
|
|
|
|
\ g:output
|
2017-02-16 22:19:53 +00:00
|
|
|
|
|
|
|
Given testft.testft2 (Empty buffer with two filetypes):
|
|
|
|
Execute (ALEInfo command history should print exit codes correctly):
|
|
|
|
let g:ale_buffer_info[bufnr('%')] = {
|
|
|
|
\ 'history': [
|
|
|
|
\ {'status': 'finished', 'exit_code': 0, 'job_id': 347, 'command': 'first command'},
|
|
|
|
\ {'status': 'finished', 'exit_code': 1, 'job_id': 347, 'command': ['/bin/bash', '\c', 'last command']},
|
|
|
|
\ ],
|
|
|
|
\}
|
|
|
|
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual
|
|
|
|
\ join([
|
|
|
|
\ '',
|
|
|
|
\ ' Current Filetype: testft.testft2',
|
|
|
|
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
|
|
|
|
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
|
|
|
|
\ ' Linter Variables:',
|
|
|
|
\ g:globals_string . g:command_header,
|
|
|
|
\ '(finished - exit code 0) ''first command''',
|
|
|
|
\ '(finished - exit code 1) [''/bin/bash'', ''\c'', ''last command'']',
|
|
|
|
\ ], "\n"),
|
|
|
|
\ g:output
|
2017-02-16 23:18:57 +00:00
|
|
|
|
|
|
|
Given testft.testft2 (Empty buffer with two filetypes):
|
|
|
|
Execute (ALEInfo command history should print command output if logging is on):
|
|
|
|
let g:ale_history_log_output = 1
|
|
|
|
|
|
|
|
let g:ale_buffer_info[bufnr('%')] = {
|
|
|
|
\ 'history': [
|
|
|
|
\ {
|
|
|
|
\ 'status': 'finished',
|
|
|
|
\ 'exit_code': 0,
|
|
|
|
\ 'job_id': 347,
|
|
|
|
\ 'command': 'first command',
|
|
|
|
\ 'output': ['some', 'first command output'],
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'status': 'finished',
|
|
|
|
\ 'exit_code': 1,
|
|
|
|
\ 'job_id': 347,
|
|
|
|
\ 'command': ['/bin/bash', '\c', 'last command'],
|
|
|
|
\ 'output': ['different second command output'],
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'status': 'finished',
|
|
|
|
\ 'exit_code': 0,
|
|
|
|
\ 'job_id': 347,
|
|
|
|
\ 'command': 'command with no output',
|
|
|
|
\ 'output': [],
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\}
|
|
|
|
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
redir => g:output
|
|
|
|
silent ALEInfo
|
|
|
|
redir END
|
|
|
|
AssertEqual
|
|
|
|
\ join([
|
|
|
|
\ '',
|
|
|
|
\ ' Current Filetype: testft.testft2',
|
|
|
|
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
|
|
|
|
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
|
|
|
|
\ ' Linter Variables:',
|
|
|
|
\ g:globals_string . 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>>>',
|
|
|
|
\ '',
|
|
|
|
\ ], "\n"),
|
|
|
|
\ g:output
|