From 2f9869de44cf4b9542fc79a4c4566aa268910b23 Mon Sep 17 00:00:00 2001 From: w0rp Date: Sat, 2 Dec 2017 20:47:01 +0000 Subject: [PATCH] Escape the perl executable, and cover the callbacks with tests --- ale_linters/perl/perl.vim | 2 +- .../test_perl_command_callback.vader | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/command_callback/test_perl_command_callback.vader diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index 33288061..fcc88f35 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -12,7 +12,7 @@ function! ale_linters#perl#perl#GetExecutable(buffer) abort endfunction function! ale_linters#perl#perl#GetCommand(buffer) abort - return ale_linters#perl#perl#GetExecutable(a:buffer) + return ale#Escape(ale_linters#perl#perl#GetExecutable(a:buffer)) \ . ' ' . ale#Var(a:buffer, 'perl_perl_options') \ . ' %t' endfunction diff --git a/test/command_callback/test_perl_command_callback.vader b/test/command_callback/test_perl_command_callback.vader new file mode 100644 index 00000000..ba85e53b --- /dev/null +++ b/test/command_callback/test_perl_command_callback.vader @@ -0,0 +1,37 @@ +Before: + Save g:ale_perl_perl_executable + Save g:ale_perl_perl_options + + unlet! g:ale_perl_perl_executable + unlet! g:ale_perl_perl_options + + runtime ale_linters/perl/perl.vim + +After: + Restore + + unlet! b:ale_perl_perl_executable + unlet! b:ale_perl_perl_options + + call ale#linter#Reset() + +Execute(The default Perl command callback should be correct): + AssertEqual + \ 'perl', + \ ale_linters#perl#perl#GetExecutable(bufnr('')) + + AssertEqual + \ ale#Escape('perl') . ' -c -Mwarnings -Ilib %t', + \ ale_linters#perl#perl#GetCommand(bufnr('')) + +Execute(Overriding the executable and command should work): + let b:ale_perl_perl_executable = 'foobar' + let b:ale_perl_perl_options = '-w' + + AssertEqual + \ 'foobar', + \ ale_linters#perl#perl#GetExecutable(bufnr('')) + + AssertEqual + \ ale#Escape('foobar') . ' -w %t', + \ ale_linters#perl#perl#GetCommand(bufnr(''))