Fix #676 - Fix handling of Perl errors

This commit is contained in:
w0rp 2017-06-22 12:37:08 +01:00
parent 40f6ee4c39
commit ce2bfa88eb
4 changed files with 28 additions and 1 deletions

View File

@ -27,7 +27,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
let l:text = l:match[1]
let l:type = 'E'
if l:match[2][-len(l:basename):] ==# l:basename
if ale#path#IsBufferPath(a:buffer, l:match[2])
\&& l:text !=# 'BEGIN failed--compilation aborted'
call add(l:output, {
\ 'lnum': l:line,

View File

@ -65,6 +65,13 @@ endfunction
" Given a buffer number and a relative or absolute path, return 1 if the
" two paths represent the same file on disk.
function! ale#path#IsBufferPath(buffer, complex_filename) abort
" If the path is one of many different names for stdin, we have a match.
if a:complex_filename ==# '-'
\|| a:complex_filename ==# 'stdin'
\|| a:complex_filename[:0] ==# '<'
return 1
endif
let l:test_filename = simplify(a:complex_filename)
if l:test_filename[:1] ==# './'

View File

@ -23,3 +23,17 @@ Execute(The Perl linter should ignore errors from other files):
\ 'Compilation failed in require at ' . b:path . '/bar.pl line 2.',
\ 'BEGIN failed--compilation aborted at ' . b:path . '/bar.pl line 2.',
\ ])
Execute(The Perl linter should complain about failing to locate modules):
AssertEqual
\ [
\ {
\ 'lnum': '23',
\ 'type': 'E',
\ 'text': 'Can''t locate JustOneDb.pm in @INC (you may need to install the JustOneDb module) (@INC contains: /home/local/sean/work/PostgreSQL/6616/../../../../lib /home/local/sean/work/PostgreSQL/6616/lib lib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .)',
\ },
\ ],
\ ale_linters#perl#perl#Handle(bufnr(''), [
\ 'Can''t locate JustOneDb.pm in @INC (you may need to install the JustOneDb module) (@INC contains: /home/local/sean/work/PostgreSQL/6616/../../../../lib /home/local/sean/work/PostgreSQL/6616/lib lib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at - line 23.',
\ 'BEGIN failed--compilation aborted at - line 23.',
\ ])

View File

@ -24,3 +24,9 @@ Execute(ale#path#IsBufferPath should match paths with redundant slashes):
silent file! foo.txt
Assert ale#path#IsBufferPath(bufnr(''), getcwd() . '////foo.txt'), 'No match for foo.txt'
Execute(ale#path#IsBufferPath should accept various names for stdin):
Assert ale#path#IsBufferPath(bufnr(''), '-')
Assert ale#path#IsBufferPath(bufnr(''), 'stdin')
Assert ale#path#IsBufferPath(bufnr(''), '<stdin>')
Assert ale#path#IsBufferPath(bufnr(''), '<somethingelse>')