summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/perl/perl.vim2
-rw-r--r--autoload/ale/path.vim7
-rw-r--r--test/handler/test_perl_handler.vader14
-rw-r--r--test/test_path_equality.vader6
4 files changed, 28 insertions, 1 deletions
diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim
index 53c91d36..f4b35ab9 100644
--- a/ale_linters/perl/perl.vim
+++ b/ale_linters/perl/perl.vim
@@ -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,
diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim
index 0365ceed..e8a5de27 100644
--- a/autoload/ale/path.vim
+++ b/autoload/ale/path.vim
@@ -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] ==# './'
diff --git a/test/handler/test_perl_handler.vader b/test/handler/test_perl_handler.vader
index 2961b266..b8b7b6c7 100644
--- a/test/handler/test_perl_handler.vader
+++ b/test/handler/test_perl_handler.vader
@@ -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.',
+ \ ])
diff --git a/test/test_path_equality.vader b/test/test_path_equality.vader
index 5d92794f..7043eb5f 100644
--- a/test/test_path_equality.vader
+++ b/test/test_path_equality.vader
@@ -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>')