Compare commits

...

4 Commits

Author SHA1 Message Date
w0rp c7a9ffcb9c Fix #1298 - Escape commands for PowerShell 2018-02-25 14:23:08 +00:00
w0rp af1b881c8b Merge pull request #1322 from datanoise/master
fixed rust errors parsing
2018-01-29 13:55:14 +00:00
w0rp 80e973a29e Merge pull request #1256 from jonatanolofsson/master
Fix #1255: Move extra clang-check args to before user options
2018-01-12 12:10:04 +00:00
w0rp 2381b7afe8 Merge pull request #1254 from bkhl/master
Don't use temporary file for rustfmt fixer
2018-01-02 13:36:59 +00:00
10 changed files with 89 additions and 32 deletions

View File

@ -24,9 +24,9 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
" detected.
return ale#Escape(ale_linters#cpp#clangcheck#GetExecutable(a:buffer))
\ . ' -analyze %s'
\ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '')
\ . (!empty(l:user_options) ? ' ' . l:user_options : '')
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (empty(l:build_dir) ? ' -extra-arg -Xanalyzer -extra-arg -analyzer-output=text' : '')
endfunction
call ale#linter#Define('cpp', {

View File

@ -10,8 +10,6 @@ function! ale#fixers#rustfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\ . (empty(l:options) ? '' : ' ' . l:options),
\}
endfunction

View File

@ -51,8 +51,8 @@ function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort
call add(l:output, {
\ 'lnum': l:span.line_start,
\ 'end_lnum': l:span.line_end,
\ 'col': l:span.byte_start,
\ 'end_col': l:span.byte_end,
\ 'col': l:span.column_start,
\ 'end_col': l:span.column_end,
\ 'text': empty(l:span.label) ? l:error.message : printf('%s: %s', l:error.message, l:span.label),
\ 'type': toupper(l:error.level[0]),
\})

View File

@ -174,7 +174,7 @@ function! ale#job#PrepareCommand(command) abort
" but we'll do this explicitly, so we use thes same exact command for both
" versions.
if ale#Has('win32')
return 'cmd /c ' . a:command
return 'cmd /s/c "' . a:command . '"'
endif
if &shell =~? 'fish$'

View File

@ -28,7 +28,7 @@ Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('clang-check')
\ . ' -analyze %s'
\ . ' -extra-arg -Xanalyzer -extra-arg -analyzer-output=text',
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
\ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
let b:ale_cpp_clangcheck_executable = 'foobar'
@ -38,7 +38,7 @@ Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('foobar')
\ . ' -analyze %s'
\ . ' -extra-arg -Xanalyzer -extra-arg -analyzer-output=text',
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
\ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
Execute(The options should be configurable):
@ -46,8 +46,9 @@ Execute(The options should be configurable):
AssertEqual
\ ale#Escape('clang-check')
\ . ' -analyze %s --something'
\ . ' -extra-arg -Xanalyzer -extra-arg -analyzer-output=text',
\ . ' -analyze %s'
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text'
\ . ' --something',
\ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
Execute(The build directory should be used when set):

View File

@ -18,9 +18,7 @@ Execute(The rustfmt callback should return the correct default values):
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' %t',
\ 'command': ale#Escape('xxxinvalid'),
\ },
\ ale#fixers#rustfmt#Fix(bufnr(''))
@ -30,9 +28,7 @@ Execute(The rustfmt callback should include custom rustfmt options):
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_rust_rustfmt_options
\ . ' %t',
\ . ' ' . g:ale_rust_rustfmt_options,
\ },
\ ale#fixers#rustfmt#Fix(bufnr(''))

View File

@ -7,16 +7,16 @@ Execute(The Rust handler should handle rustc output):
\ 'lnum': 15,
\ 'end_lnum': 15,
\ 'type': 'E',
\ 'col': 418,
\ 'end_col': 421,
\ 'col': 5,
\ 'end_col': 8,
\ 'text': 'expected one of `.`, `;`, `?`, `}`, or an operator, found `for`',
\ },
\ {
\ 'lnum': 13,
\ 'end_lnum': 13,
\ 'type': 'E',
\ 'col': 407,
\ 'end_col': 410,
\ 'col': 7,
\ 'end_col': 10,
\ 'text': 'no method named `wat` found for type `std::string::String` in the current scope',
\ },
\ ],
@ -83,16 +83,16 @@ Execute(The Rust handler should handle cargo output):
\ 'lnum': 15,
\ 'end_lnum': 15,
\ 'type': 'E',
\ 'col': 11505,
\ 'end_col': 11508,
\ 'col': 5,
\ 'end_col': 8,
\ 'text': 'expected one of `.`, `;`, `?`, `}`, or an operator, found `for`',
\ },
\ {
\ 'lnum': 13,
\ 'end_lnum': 13,
\ 'type': 'E',
\ 'col': 11494,
\ 'end_col': 11497,
\ 'col': 7,
\ 'end_col': 10,
\ 'text': 'no method named `wat` found for type `std::string::String` in the current scope',
\ },
\ ],
@ -157,8 +157,8 @@ Execute(The Rust handler should should errors from expansion spans):
\ 'lnum': 4,
\ 'end_lnum': 4,
\ 'type': 'E',
\ 'col': 52,
\ 'end_col': 54,
\ 'col': 21,
\ 'end_col': 23,
\ 'text': 'mismatched types: expected bool, found integral variable',
\ },
\ ],
@ -207,8 +207,8 @@ Execute(The Rust handler should show detailed errors):
\ 'lnum': 4,
\ 'end_lnum': 4,
\ 'type': 'E',
\ 'col': 52,
\ 'end_col': 54,
\ 'col': 21,
\ 'end_col': 23,
\ 'text': 'mismatched types: expected bool, found integral variable',
\ },
\ ],

View File

@ -1,6 +1,7 @@
Before:
Save g:ale_set_lists_synchronously
Save g:ale_buffer_info
Save &shell
let g:ale_buffer_info = {}
let g:ale_set_lists_synchronously = 1
@ -59,6 +60,67 @@ Execute(Linters should run with the default options):
\ 'valid': 1,
\ }], getloclist(0)
Execute(Linters should run in PowerShell too):
if has('win32')
set shell=powershell
AssertEqual 'foobar', &filetype
" Replace the callback to handle two lines.
function! TestCallback(buffer, output)
" Windows adds extra spaces to the text from echo.
return [
\ {
\ 'lnum': 1,
\ 'col': 3,
\ 'text': substitute(a:output[0], ' *$', '', ''),
\ },
\ {
\ 'lnum': 2,
\ 'col': 3,
\ 'text': substitute(a:output[1], ' *$', '', ''),
\ },
\]
endfunction
" Recreate the command string to use &&, which PowerShell does not support.
call ale#linter#Reset()
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
\ 'executable': 'cmd',
\ 'command': 'echo foo && echo bar',
\})
call ale#Lint()
call ale#engine#WaitForJobs(2000)
AssertEqual [
\ {
\ 'bufnr': bufnr('%'),
\ 'lnum': 1,
\ 'vcol': 0,
\ 'col': 3,
\ 'text': 'foo',
\ 'type': 'E',
\ 'nr': -1,
\ 'pattern': '',
\ 'valid': 1,
\ },
\ {
\ 'bufnr': bufnr('%'),
\ 'lnum': 2,
\ 'vcol': 0,
\ 'col': 3,
\ 'text': 'bar',
\ 'type': 'E',
\ 'nr': -1,
\ 'pattern': '',
\ 'valid': 1,
\ },
\], getloclist(0)
endif
Execute(Previous errors should be removed when linters change):
call ale#Lint()
call ale#engine#WaitForJobs(2000)

View File

@ -76,7 +76,7 @@ Execute(History should be set when commands are run):
AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
if has('win32')
AssertEqual 'cmd /c echo command history test', g:history[0].command
AssertEqual 'cmd /s/c "echo command history test"', g:history[0].command
else
AssertEqual ['/bin/sh', '-c', '/bin/sh -c ''echo command history test'''], g:history[0].command
endif
@ -151,7 +151,7 @@ Execute(The history should be updated when fixers are run):
AssertEqual ['finished'], map(copy(b:ale_history), 'v:val.status')
if has('win32')
AssertEqual 'cmd /c echo foo ', split(b:ale_history[0].command, '<')[0]
AssertEqual 'cmd /s/c "echo foo ', split(b:ale_history[0].command, '<')[0]
else
AssertEqual '/bin/sh -c echo foo ', split(join(b:ale_history[0].command), '<')[0]
endif

View File

@ -35,4 +35,4 @@ Execute(cmd /c as a string should be used on Windows):
let &shellcmdflag = 'whatever'
let g:ale_has_override = {'win32': 1}
AssertEqual 'cmd /c foobar', ale#job#PrepareCommand('foobar')
AssertEqual 'cmd /s/c "foobar"', ale#job#PrepareCommand('foobar')