diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim index 9cebcf5..2909dab 100644 --- a/autoload/ale/job.vim +++ b/autoload/ale/job.vim @@ -205,7 +205,7 @@ function! ale#job#PrepareCommand(buffer, command) abort " but we'll do this explicitly, so we use the same exact command for both " versions. if has('win32') - return 'cmd /c ' . l:command + return 'cmd /s/c "' . l:command . '"' endif if &shell =~? 'fish$' diff --git a/test/smoke_test.vader b/test/smoke_test.vader index 7635cbd..f6d0be5 100644 --- a/test/smoke_test.vader +++ b/test/smoke_test.vader @@ -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) diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader index 020ceb5..7dabcd9 100644 --- a/test/test_history_saving.vader +++ b/test/test_history_saving.vader @@ -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 diff --git a/test/test_prepare_command.vader b/test/test_prepare_command.vader index 16772e8..ed9272a 100644 --- a/test/test_prepare_command.vader +++ b/test/test_prepare_command.vader @@ -30,10 +30,10 @@ Execute(Other shells should be used when set): AssertEqual ['/bin/bash', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar') endif -Execute(cmd /c as a string should be used on Windows): +Execute(cmd /s/c as a string should be used on Windows): if has('win32') let &shell = 'who cares' let &shellcmdflag = 'whatever' - AssertEqual 'cmd /c foobar', ale#job#PrepareCommand(bufnr(''), 'foobar') + AssertEqual 'cmd /s/c "foobar"', ale#job#PrepareCommand(bufnr(''), 'foobar') endif