Fix #625 Ignore Perl errors from other files
This commit is contained in:
parent
7db805b0cd
commit
eeea72e167
@ -20,17 +20,21 @@ endfunction
|
|||||||
function! ale_linters#perl#perl#Handle(buffer, lines) abort
|
function! ale_linters#perl#perl#Handle(buffer, lines) abort
|
||||||
let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)'
|
let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
let l:basename = expand('#' . a:buffer . ':t')
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:line = l:match[3]
|
let l:line = l:match[3]
|
||||||
let l:text = l:match[1]
|
let l:text = l:match[1]
|
||||||
let l:type = 'E'
|
let l:type = 'E'
|
||||||
|
|
||||||
call add(l:output, {
|
if l:match[2][-len(l:basename):] ==# l:basename
|
||||||
\ 'lnum': l:line,
|
\&& l:text !=# 'BEGIN failed--compilation aborted'
|
||||||
\ 'text': l:text,
|
call add(l:output, {
|
||||||
\ 'type': l:type,
|
\ 'lnum': l:line,
|
||||||
\})
|
\ 'text': l:text,
|
||||||
|
\ 'type': l:type,
|
||||||
|
\})
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
|
25
test/handler/test_perl_handler.vader
Normal file
25
test/handler/test_perl_handler.vader
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
Before:
|
||||||
|
" Switch to the test rails directory.
|
||||||
|
let b:path = getcwd()
|
||||||
|
silent! cd /testplugin/test/handler
|
||||||
|
|
||||||
|
runtime ale_linters/perl/perl.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
silent! 'cd ' . fnameescape(b:path)
|
||||||
|
unlet! b:path
|
||||||
|
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(The Perl linter should ignore errors from other files):
|
||||||
|
silent! noautocmd file bar.pl
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'lnum': '2', 'type': 'E', 'text': 'Compilation failed in require'},
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#perl#perl#Handle(bufnr(''), [
|
||||||
|
\ 'syntax error at ' . b:path . '/foo.pm line 4, near "aklsdfjmy "',
|
||||||
|
\ 'Compilation failed in require at ' . b:path . '/bar.pl line 2.',
|
||||||
|
\ 'BEGIN failed--compilation aborted at ' . b:path . '/bar.pl line 2.',
|
||||||
|
\ ])
|
Loading…
Reference in New Issue
Block a user